const gchar * function,
gint line);
+#define GST_D3D11_CLEAR_COM(obj) G_STMT_START { \
+ if (obj) { \
+ (obj)->Release (); \
+ (obj) = NULL; \
+ } \
+ } G_STMT_END
+
G_END_DECLS
#endif /* __GST_D3D11_PRIVATE_H__ */
static void
gst_d3d11_buffer_pool_init (GstD3D11BufferPool * self)
{
- self->priv = gst_d3d11_buffer_pool_get_instance_private (self);
+ self->priv = (GstD3D11BufferPoolPrivate *)
+ gst_d3d11_buffer_pool_get_instance_private (self);
}
static void
if (!priv->d3d11_params) {
/* allocate memory with resource format by default */
priv->d3d11_params =
- gst_d3d11_allocation_params_new (self->device, &info, 0, 0);
+ gst_d3d11_allocation_params_new (self->device,
+ &info, (GstD3D11AllocationFlags) 0, 0);
}
desc = priv->d3d11_params->desc;
{
GstD3D11BufferPoolPrivate *priv = self->priv;
GstFlowReturn ret = GST_FLOW_OK;
- gint i;
+ guint i;
for (i = 0; i < G_N_ELEMENTS (priv->alloc); i++) {
GstMemory *mem = NULL;
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
- pool = g_object_new (GST_TYPE_D3D11_BUFFER_POOL, NULL);
+ pool = (GstD3D11BufferPool *) g_object_new (GST_TYPE_D3D11_BUFFER_POOL, NULL);
gst_object_ref_sink (pool);
- pool->device = gst_object_ref (device);
+ pool->device = (GstD3D11Device *) gst_object_ref (device);
return GST_BUFFER_POOL_CAST (pool);
}
#include "gstd3d11_private.h"
#include "gstd3d11memory.h"
#include <gmodule.h>
+#include <wrl.h>
#include <windows.h>
#include <versionhelpers.h>
* and gst_d3d11_device_unlock()
*/
+/* *INDENT-OFF* */
+using namespace Microsoft::WRL;
+/* *INDENT-ON* */
+
#if HAVE_D3D11SDKLAYERS_H
#include <d3d11sdklayers.h>
static GModule *d3d11_debug_module = NULL;
SIZE_T msg_len = 0;
HRESULT hr;
UINT64 num_msg, i;
+ ID3D11InfoQueue *info_queue = priv->d3d11_info_queue;
- if (!priv->d3d11_info_queue)
+ if (!info_queue)
return;
- num_msg = ID3D11InfoQueue_GetNumStoredMessages (priv->d3d11_info_queue);
+ num_msg = info_queue->GetNumStoredMessages ();
for (i = 0; i < num_msg; i++) {
GstDebugLevel level;
- hr = ID3D11InfoQueue_GetMessage (priv->d3d11_info_queue, i, NULL, &msg_len);
+ hr = info_queue->GetMessage (i, NULL, &msg_len);
if (FAILED (hr) || msg_len == 0) {
return;
}
msg = (D3D11_MESSAGE *) g_alloca (msg_len);
- hr = ID3D11InfoQueue_GetMessage (priv->d3d11_info_queue, i, msg, &msg_len);
+ hr = info_queue->GetMessage (i, msg, &msg_len);
level = d3d11_message_severity_to_gst (msg->Severity);
if (msg->Category == D3D11_MESSAGE_CATEGORY_STATE_CREATION &&
G_OBJECT (device), "D3D11InfoQueue: %s", msg->pDescription);
}
- ID3D11InfoQueue_ClearStoredMessages (priv->d3d11_info_queue);
+ info_queue->ClearStoredMessages ();
return;
}
SIZE_T msg_len = 0;
HRESULT hr;
UINT64 num_msg, i;
+ IDXGIInfoQueue *info_queue = priv->dxgi_info_queue;
- if (!priv->dxgi_info_queue)
+ if (!info_queue)
return;
- num_msg = IDXGIInfoQueue_GetNumStoredMessages (priv->dxgi_info_queue,
- DXGI_DEBUG_ALL);
+ num_msg = info_queue->GetNumStoredMessages (DXGI_DEBUG_ALL);
for (i = 0; i < num_msg; i++) {
GstDebugLevel level;
- hr = IDXGIInfoQueue_GetMessage (priv->dxgi_info_queue,
- DXGI_DEBUG_ALL, i, NULL, &msg_len);
+ hr = info_queue->GetMessage (DXGI_DEBUG_ALL, i, NULL, &msg_len);
if (FAILED (hr) || msg_len == 0) {
return;
}
msg = (DXGI_INFO_QUEUE_MESSAGE *) g_alloca (msg_len);
- hr = IDXGIInfoQueue_GetMessage (priv->dxgi_info_queue,
- DXGI_DEBUG_ALL, i, msg, &msg_len);
+ hr = info_queue->GetMessage (DXGI_DEBUG_ALL, i, msg, &msg_len);
level = dxgi_info_queue_message_severity_to_gst (msg->Severity);
gst_debug_log (gst_d3d11_debug_layer_debug, level, file, function, line,
G_OBJECT (device), "DXGIInfoQueue: %s", msg->pDescription);
}
- IDXGIInfoQueue_ClearStoredMessages (priv->dxgi_info_queue, DXGI_DEBUG_ALL);
+ info_queue->ClearStoredMessages (DXGI_DEBUG_ALL);
return;
}
gst_d3d11_device_class_init (GstD3D11DeviceClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GParamFlags rw_construct_only_flags =
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+ GParamFlags readable_flags =
+ (GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
gobject_class->set_property = gst_d3d11_device_set_property;
gobject_class->get_property = gst_d3d11_device_get_property;
g_object_class_install_property (gobject_class, PROP_ADAPTER,
g_param_spec_uint ("adapter", "Adapter",
"DXGI Adapter index for creating device",
- 0, G_MAXUINT32, DEFAULT_ADAPTER,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ 0, G_MAXUINT32, DEFAULT_ADAPTER, rw_construct_only_flags));
g_object_class_install_property (gobject_class, PROP_DEVICE_ID,
g_param_spec_uint ("device-id", "Device Id",
- "DXGI Device ID", 0, G_MAXUINT32, 0,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ "DXGI Device ID", 0, G_MAXUINT32, 0, readable_flags));
g_object_class_install_property (gobject_class, PROP_VENDOR_ID,
g_param_spec_uint ("vendor-id", "Vendor Id",
- "DXGI Vendor ID", 0, G_MAXUINT32, 0,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ "DXGI Vendor ID", 0, G_MAXUINT32, 0, readable_flags));
g_object_class_install_property (gobject_class, PROP_HARDWARE,
g_param_spec_boolean ("hardware", "Hardware",
- "Whether hardware device or not", TRUE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ "Whether hardware device or not", TRUE, readable_flags));
g_object_class_install_property (gobject_class, PROP_DESCRIPTION,
g_param_spec_string ("description", "Description",
- "Human readable device description", NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ "Human readable device description", NULL, readable_flags));
g_object_class_install_property (gobject_class, PROP_ALLOW_TEARING,
g_param_spec_boolean ("allow-tearing", "Allow tearing",
"Whether dxgi device supports allow-tearing feature or not", FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ readable_flags));
g_object_class_install_property (gobject_class, PROP_CREATE_FLAGS,
g_param_spec_uint ("create-flags", "Create flags",
"D3D11_CREATE_DEVICE_FLAG flags used for D3D11CreateDevice",
- 0, G_MAXUINT32, DEFAULT_CREATE_FLAGS,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ 0, G_MAXUINT32, DEFAULT_CREATE_FLAGS, rw_construct_only_flags));
g_object_class_install_property (gobject_class, PROP_ADAPTER_LUID,
g_param_spec_int64 ("adapter-luid", "Adapter LUID",
"DXGI Adapter LUID (Locally Unique Identifier) of created device",
- 0, G_MAXINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ 0, G_MAXINT64, 0, readable_flags));
gst_d3d11_memory_init_once ();
}
{
GstD3D11DevicePrivate *priv;
- priv = gst_d3d11_device_get_instance_private (self);
+ priv = (GstD3D11DevicePrivate *)
+ gst_d3d11_device_get_instance_private (self);
priv->adapter = DEFAULT_ADAPTER;
g_rec_mutex_init (&priv->extern_lock);
return ret;
}
+inline D3D11_FORMAT_SUPPORT
+operator | (D3D11_FORMAT_SUPPORT lhs, D3D11_FORMAT_SUPPORT rhs)
+{
+ return static_cast < D3D11_FORMAT_SUPPORT > (static_cast < UINT >
+ (lhs) | static_cast < UINT > (rhs));
+}
+
+inline D3D11_FORMAT_SUPPORT
+operator |= (D3D11_FORMAT_SUPPORT lhs, D3D11_FORMAT_SUPPORT rhs)
+{
+ return lhs | rhs;
+}
+
static gboolean
can_support_format (GstD3D11Device * self, DXGI_FORMAT format,
D3D11_FORMAT_SUPPORT extra_flags)
return FALSE;
}
- hr = ID3D11Device_CheckFormatSupport (handle, format, &supported);
+ hr = handle->CheckFormatSupport (format, &supported);
if (FAILED (hr)) {
GST_DEBUG_OBJECT (self, "DXGI format %d is not supported by device",
(guint) format);
{
GstD3D11Device *self = GST_D3D11_DEVICE (object);
GstD3D11DevicePrivate *priv = self->priv;
- IDXGIAdapter1 *adapter = NULL;
- IDXGIFactory1 *factory = NULL;
+ ComPtr < IDXGIAdapter1 > adapter;
+ ComPtr < IDXGIFactory1 > factory;
HRESULT hr;
UINT d3d11_flags = priv->create_flags;
GST_CAT_INFO_OBJECT (gst_d3d11_debug_layer_debug, self,
"dxgi debug library was loaded");
- hr = gst_d3d11_device_dxgi_get_device_interface (&IID_IDXGIDebug,
- (void **) &debug);
+ hr = gst_d3d11_device_dxgi_get_device_interface (IID_PPV_ARGS (&debug));
if (SUCCEEDED (hr)) {
GST_CAT_INFO_OBJECT (gst_d3d11_debug_layer_debug, self,
"IDXGIDebug interface available");
priv->dxgi_debug = debug;
- hr = gst_d3d11_device_dxgi_get_device_interface (&IID_IDXGIInfoQueue,
- (void **) &info_queue);
+ hr = gst_d3d11_device_dxgi_get_device_interface (IID_PPV_ARGS
+ (&info_queue));
if (SUCCEEDED (hr)) {
GST_CAT_INFO_OBJECT (gst_d3d11_debug_layer_debug, self,
"IDXGIInfoQueue interface available");
}
#endif
-#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
- hr = CreateDXGIFactory1 (&IID_IDXGIFactory5, (void **) &factory);
+ hr = CreateDXGIFactory1 (IID_PPV_ARGS (&factory));
if (!gst_d3d11_result (hr, NULL)) {
- GST_INFO_OBJECT (self, "IDXGIFactory5 was unavailable");
- factory = NULL;
- } else {
+ GST_ERROR_OBJECT (self, "cannot create dxgi factory, hr: 0x%x", (guint) hr);
+ goto out;
+ }
+#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
+ {
+ ComPtr < IDXGIFactory5 > factory5;
BOOL allow_tearing;
- hr = IDXGIFactory5_CheckFeatureSupport ((IDXGIFactory5 *) factory,
- DXGI_FEATURE_PRESENT_ALLOW_TEARING, (void *) &allow_tearing,
- sizeof (allow_tearing));
-
- priv->allow_tearing = SUCCEEDED (hr) && allow_tearing;
+ hr = factory.As (&factory5);
+ if (SUCCEEDED (hr)) {
+ hr = factory5->CheckFeatureSupport (DXGI_FEATURE_PRESENT_ALLOW_TEARING,
+ (void *) &allow_tearing, sizeof (allow_tearing));
- hr = S_OK;
+ priv->allow_tearing = SUCCEEDED (hr) && allow_tearing;
+ }
}
#endif
- if (!factory) {
- hr = CreateDXGIFactory1 (&IID_IDXGIFactory1, (void **) &factory);
- }
-
- if (!gst_d3d11_result (hr, NULL)) {
- GST_ERROR_OBJECT (self, "cannot create dxgi factory, hr: 0x%x", (guint) hr);
- goto error;
- }
-
- if (IDXGIFactory1_EnumAdapters1 (factory, priv->adapter,
- &adapter) == DXGI_ERROR_NOT_FOUND) {
+ if (factory->EnumAdapters1 (priv->adapter, &adapter) == DXGI_ERROR_NOT_FOUND) {
GST_DEBUG_OBJECT (self, "No adapter for index %d", priv->adapter);
- goto error;
+ goto out;
} else {
DXGI_ADAPTER_DESC1 desc;
- hr = IDXGIAdapter1_GetDesc1 (adapter, &desc);
+ hr = adapter->GetDesc1 (&desc);
if (SUCCEEDED (hr)) {
gchar *description = NULL;
gboolean is_hardware = FALSE;
adapter_luid = (((gint64) desc.AdapterLuid.HighPart) << 32) |
((gint64) desc.AdapterLuid.LowPart);
- description = g_utf16_to_utf8 (desc.Description, -1, NULL, NULL, NULL);
+ description = g_utf16_to_utf8 ((gunichar2 *) desc.Description,
+ -1, NULL, NULL, NULL);
GST_DEBUG_OBJECT (self,
"adapter index %d: D3D11 device vendor-id: 0x%04x, device-id: 0x%04x, "
"Flags: 0x%x, adapter-luid: %" G_GINT64_FORMAT ", %s",
}
#endif
- hr = D3D11CreateDevice ((IDXGIAdapter *) adapter, D3D_DRIVER_TYPE_UNKNOWN,
+ hr = D3D11CreateDevice (adapter.Get (), D3D_DRIVER_TYPE_UNKNOWN,
NULL, d3d11_flags, feature_levels, G_N_ELEMENTS (feature_levels),
D3D11_SDK_VERSION, &priv->device, &selected_level, &priv->device_context);
if (FAILED (hr)) {
/* Retry if the system could not recognize D3D_FEATURE_LEVEL_11_1 */
- hr = D3D11CreateDevice ((IDXGIAdapter *) adapter, D3D_DRIVER_TYPE_UNKNOWN,
+ hr = D3D11CreateDevice (adapter.Get (), D3D_DRIVER_TYPE_UNKNOWN,
NULL, d3d11_flags, &feature_levels[1],
G_N_ELEMENTS (feature_levels) - 1, D3D11_SDK_VERSION, &priv->device,
&selected_level, &priv->device_context);
d3d11_flags &= ~D3D11_CREATE_DEVICE_DEBUG;
- hr = D3D11CreateDevice ((IDXGIAdapter *) adapter, D3D_DRIVER_TYPE_UNKNOWN,
+ hr = D3D11CreateDevice (adapter.Get (), D3D_DRIVER_TYPE_UNKNOWN,
NULL, d3d11_flags, feature_levels, G_N_ELEMENTS (feature_levels),
D3D11_SDK_VERSION, &priv->device, &selected_level,
&priv->device_context);
if (FAILED (hr)) {
/* Retry if the system could not recognize D3D_FEATURE_LEVEL_11_1 */
- hr = D3D11CreateDevice ((IDXGIAdapter *) adapter, D3D_DRIVER_TYPE_UNKNOWN,
+ hr = D3D11CreateDevice (adapter.Get (), D3D_DRIVER_TYPE_UNKNOWN,
NULL, d3d11_flags, &feature_levels[1],
G_N_ELEMENTS (feature_levels) - 1, D3D11_SDK_VERSION, &priv->device,
&selected_level, &priv->device_context);
GST_INFO_OBJECT (self,
"cannot create d3d11 device for adapter index %d with flags 0x%x, "
"hr: 0x%x", priv->adapter, d3d11_flags, (guint) hr);
- goto error;
+ goto out;
}
- priv->factory = factory;
+ priv->factory = factory.Detach ();
#if HAVE_D3D11SDKLAYERS_H
if ((d3d11_flags & D3D11_CREATE_DEVICE_DEBUG) == D3D11_CREATE_DEVICE_DEBUG) {
ID3D11Debug *debug;
ID3D11InfoQueue *info_queue;
- hr = ID3D11Device_QueryInterface (priv->device,
- &IID_ID3D11Debug, (void **) &debug);
+ hr = priv->device->QueryInterface (IID_PPV_ARGS (&debug));
if (SUCCEEDED (hr)) {
GST_CAT_INFO_OBJECT (gst_d3d11_debug_layer_debug, self,
"D3D11Debug interface available");
priv->d3d11_debug = debug;
- hr = ID3D11Device_QueryInterface (priv->device,
- &IID_ID3D11InfoQueue, (void **) &info_queue);
+ hr = priv->device->QueryInterface (IID_PPV_ARGS (&info_queue));
if (SUCCEEDED (hr)) {
GST_CAT_INFO_OBJECT (gst_d3d11_debug_layer_debug, self,
"ID3D11InfoQueue interface available");
* might be added by us */
priv->create_flags = d3d11_flags;
- IDXGIAdapter1_Release (adapter);
gst_d3d11_device_setup_format_table (self);
- G_OBJECT_CLASS (parent_class)->constructed (object);
-
- return;
-
-error:
- if (factory)
- IDXGIFactory1_Release (factory);
-
- if (adapter)
- IDXGIAdapter1_Release (adapter);
-
+out:
G_OBJECT_CLASS (parent_class)->constructed (object);
return;
GST_LOG_OBJECT (self, "dispose");
- if (priv->video_device) {
- ID3D11VideoDevice_Release (priv->video_device);
- priv->video_device = NULL;
- }
-
- if (priv->video_context) {
- ID3D11VideoContext_Release (priv->video_context);
- priv->video_context = NULL;
- }
-
- if (priv->device) {
- ID3D11Device_Release (priv->device);
- priv->device = NULL;
- }
-
- if (priv->device_context) {
- ID3D11DeviceContext_Release (priv->device_context);
- priv->device_context = NULL;
- }
-
- if (priv->factory) {
- IDXGIFactory1_Release (priv->factory);
- priv->factory = NULL;
- }
+ GST_D3D11_CLEAR_COM (priv->video_device);
+ GST_D3D11_CLEAR_COM (priv->video_context);
+ GST_D3D11_CLEAR_COM (priv->device);
+ GST_D3D11_CLEAR_COM (priv->device_context);
+ GST_D3D11_CLEAR_COM (priv->factory);
#if HAVE_D3D11SDKLAYERS_H
if (priv->d3d11_debug) {
- ID3D11Debug_ReportLiveDeviceObjects (priv->d3d11_debug,
- (D3D11_RLDO_FLAGS) GST_D3D11_RLDO_FLAGS);
- ID3D11Debug_Release (priv->d3d11_debug);
- priv->d3d11_debug = NULL;
+ priv->d3d11_debug->ReportLiveDeviceObjects ((D3D11_RLDO_FLAGS)
+ GST_D3D11_RLDO_FLAGS);
}
+ GST_D3D11_CLEAR_COM (priv->d3d11_debug);
- if (priv->d3d11_info_queue) {
+ if (priv->d3d11_info_queue)
gst_d3d11_device_d3d11_debug (self, __FILE__, GST_FUNCTION, __LINE__);
- ID3D11InfoQueue_Release (priv->d3d11_info_queue);
- priv->d3d11_info_queue = NULL;
- }
+ GST_D3D11_CLEAR_COM (priv->d3d11_info_queue);
#endif
#if HAVE_DXGIDEBUG_H
if (priv->dxgi_debug) {
- IDXGIDebug_ReportLiveObjects (priv->dxgi_debug, DXGI_DEBUG_ALL,
+ priv->dxgi_debug->ReportLiveObjects (DXGI_DEBUG_ALL,
(DXGI_DEBUG_RLO_FLAGS) GST_D3D11_RLDO_FLAGS);
- IDXGIDebug_Release (priv->dxgi_debug);
- priv->dxgi_debug = NULL;
}
+ GST_D3D11_CLEAR_COM (priv->dxgi_debug);
- if (priv->dxgi_info_queue) {
+ if (priv->dxgi_info_queue)
gst_d3d11_device_dxgi_debug (self, __FILE__, GST_FUNCTION, __LINE__);
- IDXGIInfoQueue_Release (priv->dxgi_info_queue);
- priv->dxgi_info_queue = NULL;
- }
+ GST_D3D11_CLEAR_COM (priv->dxgi_info_queue);
#endif
G_OBJECT_CLASS (parent_class)->dispose (object);
GstD3D11Device *device = NULL;
GstD3D11DevicePrivate *priv;
- device = g_object_new (GST_TYPE_D3D11_DEVICE, "adapter", adapter,
+ device = (GstD3D11Device *)
+ g_object_new (GST_TYPE_D3D11_DEVICE, "adapter", adapter,
"create-flags", flags, NULL);
priv = device->priv;
g_mutex_lock (&priv->resource_lock);
if (!priv->video_device) {
HRESULT hr;
+ ID3D11VideoDevice *video_device = NULL;
- hr = ID3D11Device_QueryInterface (priv->device, &IID_ID3D11VideoDevice,
- (void **) &priv->video_device);
- gst_d3d11_result (hr, device);
+ hr = priv->device->QueryInterface (IID_PPV_ARGS (&video_device));
+ if (gst_d3d11_result (hr, device))
+ priv->video_device = video_device;
}
g_mutex_unlock (&priv->resource_lock);
g_mutex_lock (&priv->resource_lock);
if (!priv->video_context) {
HRESULT hr;
+ ID3D11VideoContext *video_context = NULL;
- hr = ID3D11DeviceContext_QueryInterface (priv->device_context,
- &IID_ID3D11VideoContext, (void **) &priv->video_context);
- gst_d3d11_result (hr, device);
+ hr = priv->device_context->QueryInterface (IID_PPV_ARGS (&video_context));
+ if (gst_d3d11_result (hr, device))
+ priv->video_context = video_context;
}
g_mutex_unlock (&priv->resource_lock);
GstVideoFormat format)
{
GstD3D11DevicePrivate *priv;
- gint i;
+ guint i;
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
#include "gstd3d11memory.h"
#include "gstd3d11device.h"
#include "gstd3d11utils.h"
+#include "gstd3d11_private.h"
GST_DEBUG_CATEGORY_STATIC (gst_d3d11_allocator_debug);
#define GST_CAT_DEFAULT gst_d3d11_allocator_debug
{
GstD3D11AllocationParams *ret;
const GstD3D11Format *d3d11_format;
- gint i;
+ guint i;
g_return_val_if_fail (info != NULL, NULL);
gst_d3d11_allocation_params_alignment (GstD3D11AllocationParams * params,
GstVideoAlignment * align)
{
- gint i;
+ guint i;
guint padding_width, padding_height;
GstVideoInfo *info;
GstVideoInfo new_info;
desc.Usage = D3D11_USAGE_STAGING;
desc.CPUAccessFlags = (D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE);
- hr = ID3D11Device_CreateTexture2D (device_handle, &desc, NULL, &texture);
+ hr = device_handle->CreateTexture2D (&desc, NULL, &texture);
if (!gst_d3d11_result (hr, device)) {
GST_ERROR_OBJECT (device, "Failed to create texture");
return NULL;
ID3D11DeviceContext *device_context =
gst_d3d11_device_get_device_context_handle (dmem->device);
- hr = ID3D11DeviceContext_Map (device_context,
- staging, 0, map_type, 0, &priv->map);
+ hr = device_context->Map (staging, 0, map_type, 0, &priv->map);
if (!gst_d3d11_result (hr, dmem->device)) {
GST_ERROR_OBJECT (GST_MEMORY_CAST (dmem)->allocator,
return;
device_context = gst_d3d11_device_get_device_context_handle (dmem->device);
- ID3D11DeviceContext_CopySubresourceRegion (device_context,
- (ID3D11Resource *) priv->texture, priv->subresource_index, 0, 0, 0,
- (ID3D11Resource *) priv->staging, 0, NULL);
+ device_context->CopySubresourceRegion (priv->texture, priv->subresource_index,
+ 0, 0, 0, priv->staging, 0, NULL);
}
/* Must be called with d3d11 device lock */
return;
device_context = gst_d3d11_device_get_device_context_handle (dmem->device);
- ID3D11DeviceContext_CopySubresourceRegion (device_context,
- (ID3D11Resource *) priv->staging, 0, 0, 0, 0,
- (ID3D11Resource *) priv->texture, priv->subresource_index, NULL);
+ device_context->CopySubresourceRegion (priv->staging, 0, 0, 0, 0,
+ priv->texture, priv->subresource_index, NULL);
}
static gpointer
ID3D11DeviceContext *device_context =
gst_d3d11_device_get_device_context_handle (dmem->device);
- ID3D11DeviceContext_Unmap (device_context, staging, 0);
+ device_context->Unmap (staging, 0);
}
static void
GST_DEBUG_CATEGORY_INIT (gst_d3d11_allocator_debug, "d3d11allocator", 0,
"Direct3D11 Texture Allocator");
- _d3d11_memory_allocator = g_object_new (GST_TYPE_D3D11_ALLOCATOR, NULL);
+ _d3d11_memory_allocator =
+ (GstAllocator *) g_object_new (GST_TYPE_D3D11_ALLOCATOR, NULL);
gst_object_ref_sink (_d3d11_memory_allocator);
gst_allocator_register (GST_D3D11_MEMORY_NAME, _d3d11_memory_allocator);
create_shader_resource_views (GstD3D11Memory * mem)
{
GstD3D11MemoryPrivate *priv = mem->priv;
- gint i;
+ guint i;
HRESULT hr;
guint num_views = 0;
ID3D11Device *device_handle;
- D3D11_SHADER_RESOURCE_VIEW_DESC resource_desc = { 0, };
+ D3D11_SHADER_RESOURCE_VIEW_DESC resource_desc;
DXGI_FORMAT formats[GST_VIDEO_MAX_PLANES] = { DXGI_FORMAT_UNKNOWN, };
+ memset (&resource_desc, 0, sizeof (D3D11_SHADER_RESOURCE_VIEW_DESC));
+
device_handle = gst_d3d11_device_get_device_handle (mem->device);
switch (priv->desc.Format) {
for (i = 0; i < num_views; i++) {
resource_desc.Format = formats[i];
- hr = ID3D11Device_CreateShaderResourceView (device_handle,
- (ID3D11Resource *) priv->texture, &resource_desc,
- &priv->shader_resource_view[i]);
+ hr = device_handle->CreateShaderResourceView (priv->texture,
+ &resource_desc, &priv->shader_resource_view[i]);
if (!gst_d3d11_result (hr, mem->device)) {
GST_ERROR_OBJECT (GST_MEMORY_CAST (mem)->allocator,
return FALSE;
error:
- for (i = 0; i < num_views; i++) {
- if (priv->shader_resource_view[i])
- ID3D11ShaderResourceView_Release (priv->shader_resource_view[i]);
- priv->shader_resource_view[i] = NULL;
- }
+ for (i = 0; i < num_views; i++)
+ GST_D3D11_CLEAR_COM (priv->shader_resource_view[i]);
priv->num_shader_resource_views = 0;
create_render_target_views (GstD3D11Memory * mem)
{
GstD3D11MemoryPrivate *priv = mem->priv;
- gint i;
+ guint i;
HRESULT hr;
guint num_views = 0;
ID3D11Device *device_handle;
- D3D11_RENDER_TARGET_VIEW_DESC render_desc = { 0, };
+ D3D11_RENDER_TARGET_VIEW_DESC render_desc;
DXGI_FORMAT formats[GST_VIDEO_MAX_PLANES] = { DXGI_FORMAT_UNKNOWN, };
+ memset (&render_desc, 0, sizeof (D3D11_RENDER_TARGET_VIEW_DESC));
+
device_handle = gst_d3d11_device_get_device_handle (mem->device);
switch (priv->desc.Format) {
for (i = 0; i < num_views; i++) {
render_desc.Format = formats[i];
- hr = ID3D11Device_CreateRenderTargetView (device_handle,
- (ID3D11Resource *) priv->texture, &render_desc,
+ hr = device_handle->CreateRenderTargetView (priv->texture, &render_desc,
&priv->render_target_view[i]);
if (!gst_d3d11_result (hr, mem->device)) {
GST_ERROR_OBJECT (GST_MEMORY_CAST (mem)->allocator,
return FALSE;
error:
- for (i = 0; i < num_views; i++) {
- if (priv->render_target_view[i])
- ID3D11RenderTargetView_Release (priv->render_target_view[i]);
- priv->render_target_view[i] = NULL;
- }
+ for (i = 0; i < num_views; i++)
+ GST_D3D11_CLEAR_COM (priv->render_target_view[i]);
priv->num_render_target_views = 0;
GST_D3D11_MEMORY_LOCK (mem);
if (dmem_priv->decoder_output_view) {
- ID3D11VideoDecoderOutputView_GetDesc (dmem_priv->decoder_output_view,
- &desc);
- if (IsEqualGUID (&desc.DecodeProfile, decoder_profile)) {
+ dmem_priv->decoder_output_view->GetDesc (&desc);
+ if (IsEqualGUID (desc.DecodeProfile, *decoder_profile)) {
goto succeeded;
} else {
/* Shouldn't happen, but try again anyway */
GST_WARNING_OBJECT (allocator,
"Existing view has different decoder profile");
- ID3D11VideoDecoderOutputView_Release (dmem_priv->decoder_output_view);
- dmem_priv->decoder_output_view = NULL;
+ GST_D3D11_CLEAR_COM (dmem_priv->decoder_output_view);
}
}
desc.ViewDimension = D3D11_VDOV_DIMENSION_TEXTURE2D;
desc.Texture2D.ArraySlice = dmem_priv->subresource_index;
- hr = ID3D11VideoDevice_CreateVideoDecoderOutputView (video_device,
- (ID3D11Resource *) dmem_priv->texture, &desc,
+ hr = video_device->CreateVideoDecoderOutputView (dmem_priv->texture, &desc,
&dmem_priv->decoder_output_view);
if (!gst_d3d11_result (hr, mem->device)) {
GST_ERROR_OBJECT (allocator,
desc.Texture2D.MipSlice = 0;
desc.Texture2D.ArraySlice = dmem_priv->subresource_index;
- hr = ID3D11VideoDevice_CreateVideoProcessorInputView (video_device,
- (ID3D11Resource *) dmem_priv->texture, enumerator, &desc,
- &dmem_priv->processor_input_view);
+ hr = video_device->CreateVideoProcessorInputView (dmem_priv->texture,
+ enumerator, &desc, &dmem_priv->processor_input_view);
if (!gst_d3d11_result (hr, mem->device)) {
GST_ERROR_OBJECT (allocator,
"Could not create processor input view, hr: 0x%x", (guint) hr);
{
GstD3D11MemoryPrivate *priv = mem->priv;
GstD3D11Allocator *allocator;
- D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC desc = { 0, };
+ D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC desc;
HRESULT hr;
gboolean ret;
+ memset (&desc, 0, sizeof (D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC));
+
allocator = GST_D3D11_ALLOCATOR (GST_MEMORY_CAST (mem)->allocator);
if (!(priv->desc.BindFlags & D3D11_BIND_RENDER_TARGET)) {
desc.ViewDimension = D3D11_VPOV_DIMENSION_TEXTURE2D;
desc.Texture2D.MipSlice = 0;
- hr = ID3D11VideoDevice_CreateVideoProcessorOutputView (video_device,
- (ID3D11Resource *) priv->texture, enumerator, &desc,
- &priv->processor_output_view);
+ hr = video_device->CreateVideoProcessorOutputView (priv->texture,
+ enumerator, &desc, &priv->processor_output_view);
if (!gst_d3d11_result (hr, mem->device)) {
GST_ERROR_OBJECT (allocator,
"Could not create processor input view, hr: 0x%x", (guint) hr);
UINT supported_flags = 0;
/* non-zero offset or different size is not supported */
- if (offset != 0 || (size != -1 && size != mem->size)) {
+ if (offset != 0 || (size != -1 && (gsize) size != mem->size)) {
GST_DEBUG_OBJECT (alloc, "Different size/offset, try fallback copy");
return priv->fallback_copy (mem, offset, size);
}
gst_d3d11_device_lock (device);
- if (!gst_memory_map (mem, &info, GST_MAP_READ | GST_MAP_D3D11)) {
+ if (!gst_memory_map (mem, &info,
+ (GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
gst_d3d11_device_unlock (device);
GST_WARNING_OBJECT (alloc, "Failed to map memory, try fallback copy");
return priv->fallback_copy (mem, offset, size);
}
- ID3D11Texture2D_GetDesc (dmem->priv->texture, &src_desc);
+ dmem->priv->texture->GetDesc (&src_desc);
dst_desc.Width = src_desc.Width;
dst_desc.Height = src_desc.Height;
dst_desc.MipLevels = 1;
dst_desc.Usage = D3D11_USAGE_DEFAULT;
/* If supported, use bind flags for SRV/RTV */
- hr = ID3D11Device_CheckFormatSupport (device_handle,
- src_desc.Format, &supported_flags);
+ hr = device_handle->CheckFormatSupport (src_desc.Format, &supported_flags);
if (gst_d3d11_result (hr, device)) {
if ((supported_flags & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) ==
D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) {
}
copy_dmem = GST_D3D11_MEMORY_CAST (copy);
- ID3D11DeviceContext_CopySubresourceRegion (device_context,
- (ID3D11Resource *) copy_dmem->priv->texture, 0, 0, 0, 0,
- (ID3D11Resource *) dmem->priv->texture, dmem->priv->subresource_index,
- NULL);
+ device_context->CopySubresourceRegion (copy_dmem->priv->texture, 0, 0, 0, 0,
+ dmem->priv->texture, dmem->priv->subresource_index, NULL);
copy->maxsize = copy->size = mem->maxsize;
gst_memory_unmap (mem, &info);
gst_d3d11_device_unlock (device);
GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
GstD3D11AllocatorPrivate *priv;
- priv = allocator->priv = gst_d3d11_allocator_get_instance_private (allocator);
+ priv = allocator->priv = (GstD3D11AllocatorPrivate *)
+ gst_d3d11_allocator_get_instance_private (allocator);
alloc->mem_type = GST_D3D11_MEMORY_NAME;
alloc->mem_map_full = gst_d3d11_memory_map_full;
GST_LOG_OBJECT (allocator, "Free memory %p", mem);
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
- if (dmem_priv->render_target_view[i])
- ID3D11RenderTargetView_Release (dmem_priv->render_target_view[i]);
-
- if (dmem_priv->shader_resource_view[i])
- ID3D11ShaderResourceView_Release (dmem_priv->shader_resource_view[i]);
+ GST_D3D11_CLEAR_COM (dmem_priv->render_target_view[i]);
+ GST_D3D11_CLEAR_COM (dmem_priv->shader_resource_view[i]);
}
- if (dmem_priv->decoder_output_view)
- ID3D11VideoDecoderOutputView_Release (dmem_priv->decoder_output_view);
-
- if (dmem_priv->processor_input_view)
- ID3D11VideoProcessorInputView_Release (dmem_priv->processor_input_view);
-
- if (dmem_priv->processor_output_view)
- ID3D11VideoProcessorOutputView_Release (dmem_priv->processor_output_view);
-
- if (dmem_priv->texture)
- ID3D11Texture2D_Release (dmem_priv->texture);
-
- if (dmem_priv->staging)
- ID3D11Texture2D_Release (dmem_priv->staging);
+ GST_D3D11_CLEAR_COM (dmem_priv->decoder_output_view);
+ GST_D3D11_CLEAR_COM (dmem_priv->processor_input_view);
+ GST_D3D11_CLEAR_COM (dmem_priv->processor_output_view);
+ GST_D3D11_CLEAR_COM (dmem_priv->texture);
+ GST_D3D11_CLEAR_COM (dmem_priv->staging);
gst_clear_object (&dmem->device);
g_mutex_clear (&dmem_priv->lock);
mem->priv = g_new0 (GstD3D11MemoryPrivate, 1);
gst_memory_init (GST_MEMORY_CAST (mem),
- 0, GST_ALLOCATOR_CAST (self), NULL, 0, 0, 0, 0);
+ (GstMemoryFlags) 0, GST_ALLOCATOR_CAST (self), NULL, 0, 0, 0, 0);
g_mutex_init (&mem->priv->lock);
mem->priv->texture = texture;
mem->priv->desc = *desc;
- mem->device = gst_object_ref (device);
+ mem->device = (GstD3D11Device *) gst_object_ref (device);
/* This is staging texture as well */
if (desc->Usage == D3D11_USAGE_STAGING) {
mem->priv->staging = texture;
- ID3D11Texture2D_AddRef (texture);
+ texture->AddRef ();
}
return GST_MEMORY_CAST (mem);
device_handle = gst_d3d11_device_get_device_handle (device);
- hr = ID3D11Device_CreateTexture2D (device_handle, desc, NULL, &texture);
+ hr = device_handle->CreateTexture2D (desc, NULL, &texture);
if (!gst_d3d11_result (hr, device)) {
GST_ERROR_OBJECT (self, "Couldn't create texture");
return NULL;
{
GstD3D11PoolAllocatorPrivate *priv;
- priv = allocator->priv =
+ priv = allocator->priv = (GstD3D11PoolAllocatorPrivate *)
gst_d3d11_pool_allocator_get_instance_private (allocator);
g_rec_mutex_init (&priv->lock);
gst_poll_free (priv->poll);
g_rec_mutex_clear (&priv->lock);
- if (priv->texture)
- ID3D11Texture2D_Release (priv->texture);
+ GST_D3D11_CLEAR_COM (priv->texture);
G_OBJECT_CLASS (pool_alloc_parent_class)->finalize (object);
}
device_handle = gst_d3d11_device_get_device_handle (self->device);
if (!priv->texture) {
- hr = ID3D11Device_CreateTexture2D (device_handle, &priv->desc, NULL,
- &priv->texture);
+ hr = device_handle->CreateTexture2D (&priv->desc, NULL, &priv->texture);
if (!gst_d3d11_result (hr, self->device)) {
GST_ERROR_OBJECT (self, "Failed to allocate texture");
return FALSE;
for (i = 0; i < priv->desc.ArraySize; i++) {
GstMemory *mem;
- ID3D11Texture2D_AddRef (priv->texture);
+ priv->texture->AddRef ();
mem =
gst_d3d11_allocator_alloc_wrapped (GST_D3D11_ALLOCATOR_CAST
(_d3d11_memory_allocator), self->device, &priv->desc, priv->texture);
GST_LOG_OBJECT (self, "Clearing queue");
/* clear the pool */
- while ((memory = gst_atomic_queue_pop (priv->queue))) {
+ while ((memory = (GstMemory *) gst_atomic_queue_pop (priv->queue))) {
while (!gst_poll_read_control (priv->poll)) {
if (errno == EWOULDBLOCK) {
/* We put the memory into the queue but did not finish writing control
GST_LOG_OBJECT (self, "Released memory %p", mem);
GST_MINI_OBJECT_CAST (mem)->dispose = NULL;
- mem->allocator = gst_object_ref (_d3d11_memory_allocator);
+ mem->allocator = (GstAllocator *) gst_object_ref (_d3d11_memory_allocator);
gst_object_unref (self);
/* keep it around in our queue */
goto flushing;
/* try to get a memory from the queue */
- *memory = gst_atomic_queue_pop (priv->queue);
+ *memory = (GstMemory *) gst_atomic_queue_pop (priv->queue);
if (G_LIKELY (*memory)) {
while (!gst_poll_read_control (priv->poll)) {
if (errno == EWOULDBLOCK) {
gst_d3d11_memory_init_once ();
- self = g_object_new (GST_TYPE_D3D11_POOL_ALLOCATOR, NULL);
+ self = (GstD3D11PoolAllocator *)
+ g_object_new (GST_TYPE_D3D11_POOL_ALLOCATOR, NULL);
gst_object_ref_sink (self);
- self->device = gst_object_ref (device);
+ self->device = (GstD3D11Device *) gst_object_ref (device);
self->priv->desc = *desc;
return self;
g_return_val_if_fail (GST_IS_D3D11_POOL_ALLOCATOR (allocator),
GST_FLOW_ERROR);
- g_return_val_if_fail (memory != NULL, FALSE);
+ g_return_val_if_fail (memory != NULL, GST_FLOW_ERROR);
priv = allocator->priv;
GstMemory *mem = *memory;
/* Replace default allocator with ours */
gst_object_unref (mem->allocator);
- mem->allocator = gst_object_ref (allocator);
+ mem->allocator = (GstAllocator *) gst_object_ref (allocator);
GST_MINI_OBJECT_CAST (mem)->dispose = gst_d3d11_memory_release;
} else {
dec_outstanding (allocator);
static gboolean
pad_query (const GValue * item, GValue * value, gpointer user_data)
{
- GstPad *pad = g_value_get_object (item);
- GstQuery *query = user_data;
+ GstPad *pad = (GstPad *) g_value_get_object (item);
+ GstQuery *query = (GstQuery *) user_data;
gboolean res;
res = gst_pad_peer_query (pad, query);
d3d11_sources = [
- 'gstd3d11bufferpool.c',
- 'gstd3d11device.c',
- 'gstd3d11format.c',
- 'gstd3d11memory.c',
- 'gstd3d11utils.c',
+ 'gstd3d11bufferpool.cpp',
+ 'gstd3d11device.cpp',
+ 'gstd3d11format.cpp',
+ 'gstd3d11memory.cpp',
+ 'gstd3d11utils.cpp',
]
dxgi_headers = [
have_d3d11 = false
extra_c_args = [
'-DCOBJMACROS',
+]
+extra_comm_args = [
'-DGST_USE_UNSTABLE_API',
'-DBUILDING_GST_D3D11'
]
+
have_dxgi_header = false
have_d3d11_header = false
have_d3d11sdk_h = false
# don't need to be defined in gstd3d11config.h since it's gstd3d11device internal
if have_d3d11sdk_h
- extra_c_args += ['-DHAVE_D3D11SDKLAYERS_H']
+ extra_comm_args += ['-DHAVE_D3D11SDKLAYERS_H']
endif
if have_dxgidebug_h
- extra_c_args += ['-DHAVE_DXGIDEBUG_H']
+ extra_comm_args += ['-DHAVE_DXGIDEBUG_H']
+endif
+
+# MinGW 32bits compiler seems to be complaining about redundant-decls
+# when ComPtr is in use. Let's just disable the warning
+if cc.get_id() != 'msvc'
+ extra_args = cc.get_supported_arguments([
+ '-Wno-redundant-decls',
+ ])
+
+ extra_comm_args += extra_args
endif
configure_file(
gstd3d11 = library('gstd3d11-' + api_version,
d3d11_sources,
- c_args : gst_plugins_bad_args + extra_c_args,
+ c_args : gst_plugins_bad_args + extra_c_args + extra_comm_args,
+ cpp_args : gst_plugins_bad_args + extra_comm_args,
include_directories : [configinc, libsinc],
version : libversion,
soversion : soversion,