Commit 5c3879ac authored by Seungha Yang's avatar Seungha Yang 🐑 Committed by Sebastian Dröge

d3d11videosink: Add new Direct3D11 video render plugin

Direct3D11 was shipped as part of Windows7 and it's obviously
primary graphics API on Windows.

This plugin includes HDR10 rendering if following requirements are satisfied
* IDXGISwapChain4::SetHDRMetaData is available (decleared in dxgi1_5.h)
* Display can support DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 color space
* Upstream provides 10 bitdepth format with smpte-st 2084 static metadata
parent 329b2d3a
Pipeline #47200 failed with stages
in 28 minutes and 3 seconds
......@@ -87,6 +87,7 @@ option('colormanagement', type : 'feature', value : 'auto', description : 'Color
option('curl', type : 'feature', value : 'auto', description : 'cURL network source and sink plugin')
option('curl-ssh2', type : 'feature', value : 'auto', description : 'cURL network source and sink plugin libssh2 support')
option('d3dvideosink', type : 'feature', value : 'auto', description : 'Direct3D video sink plugin')
option('d3d11', type : 'feature', value : 'auto', description : 'Direct3D11 plugin')
option('dash', type : 'feature', value : 'auto', description : 'DASH demuxer plugin')
option('dc1394', type : 'feature', value : 'auto', description : 'libdc1394 IIDC camera source plugin')
option('decklink', type : 'feature', value : 'auto', description : 'DeckLink audio/video source/sink plugin')
......
/* GStreamer
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_D3D11_FWD_H__
#define __GST_D3D11_FWD_H__
#include <gst/gst.h>
/* define COBJMACROS to use d3d11 C APIs */
#ifndef COBJMACROS
#define COBJMACROS
#endif
#ifndef INITGUID
#include <initguid.h>
#endif
#include <d3d11.h>
#ifdef HAVE_DXGI_1_5_H
#include <dxgi1_5.h>
#else
#include <dxgi.h>
#endif
G_BEGIN_DECLS
typedef struct _GstD3D11Device GstD3D11Device;
typedef struct _GstD3D11DeviceClass GstD3D11DeviceClass;
typedef struct _GstD3D11DevicePrivate GstD3D11DevicePrivate;
typedef struct _GstD3D11AllocationParams GstD3D11AllocationParams;
typedef struct _GstD3D11Memory GstD3D11Memory;
typedef struct _GstD3D11Allocator GstD3D11Allocator;
typedef struct _GstD3D11AllocatorClass GstD3D11AllocatorClass;
typedef struct _GstD3D11AllocatorPrivate GstD3D11AllocatorPrivate;
typedef struct _GstD3D11BufferPool GstD3D11BufferPool;
typedef struct _GstD3D11BufferPoolClass GstD3D11BufferPoolClass;
typedef struct _GstD3D11BufferPoolPrivate GstD3D11BufferPoolPrivate;
G_END_DECLS
#endif /* __GST_D3D11_FWD_H__ */
/* GStreamer
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstd3d11bufferpool.h"
#include "gstd3d11memory.h"
#include "gstd3d11device.h"
GST_DEBUG_CATEGORY_STATIC (gst_d3d11_buffer_pool_debug);
#define GST_CAT_DEFAULT gst_d3d11_buffer_pool_debug
struct _GstD3D11BufferPoolPrivate
{
GstD3D11Device *device;
GstD3D11Allocator *allocator;
GstCaps *caps;
gboolean add_videometa;
GstD3D11AllocationParams *d3d11_params;
};
#define gst_d3d11_buffer_pool_parent_class parent_class
G_DEFINE_TYPE_WITH_PRIVATE (GstD3D11BufferPool,
gst_d3d11_buffer_pool, GST_TYPE_BUFFER_POOL);
static void gst_d3d11_buffer_pool_dispose (GObject * object);
static const gchar **gst_d3d11_buffer_pool_get_options (GstBufferPool * pool);
static gboolean gst_d3d11_buffer_pool_set_config (GstBufferPool * pool,
GstStructure * config);
static GstFlowReturn gst_d3d11_buffer_pool_alloc (GstBufferPool * pool,
GstBuffer ** buffer, GstBufferPoolAcquireParams * params);
static void
gst_d3d11_buffer_pool_class_init (GstD3D11BufferPoolClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstBufferPoolClass *bufferpool_class = GST_BUFFER_POOL_CLASS (klass);
gobject_class->dispose = gst_d3d11_buffer_pool_dispose;
bufferpool_class->get_options = gst_d3d11_buffer_pool_get_options;
bufferpool_class->set_config = gst_d3d11_buffer_pool_set_config;
bufferpool_class->alloc_buffer = gst_d3d11_buffer_pool_alloc;
GST_DEBUG_CATEGORY_INIT (gst_d3d11_buffer_pool_debug, "d3d11bufferpool", 0,
"d3d11bufferpool object");
}
static void
gst_d3d11_buffer_pool_init (GstD3D11BufferPool * self)
{
self->priv = gst_d3d11_buffer_pool_get_instance_private (self);
}
static void
gst_d3d11_buffer_pool_dispose (GObject * object)
{
GstD3D11BufferPool *self = GST_D3D11_BUFFER_POOL (object);
GstD3D11BufferPoolPrivate *priv = self->priv;
if (priv->d3d11_params)
gst_d3d11_allocation_params_free (priv->d3d11_params);
priv->d3d11_params = NULL;
gst_clear_object (&priv->device);
gst_clear_object (&priv->allocator);
gst_clear_caps (&priv->caps);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static const gchar **
gst_d3d11_buffer_pool_get_options (GstBufferPool * pool)
{
static const gchar *options[] = { GST_BUFFER_POOL_OPTION_VIDEO_META,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT,
NULL
};
return options;
}
static gboolean
gst_d3d11_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
{
GstD3D11BufferPool *self = GST_D3D11_BUFFER_POOL (pool);
GstD3D11BufferPoolPrivate *priv = self->priv;
GstVideoInfo info;
GstCaps *caps = NULL;
guint min_buffers, max_buffers;
guint max_align, n;
GstAllocator *allocator = NULL;
GstAllocationParams alloc_params;
gboolean ret = TRUE;
D3D11_TEXTURE2D_DESC *desc;
if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &min_buffers,
&max_buffers))
goto wrong_config;
if (caps == NULL)
goto no_caps;
/* now parse the caps from the config */
if (!gst_video_info_from_caps (&info, caps))
goto wrong_caps;
GST_LOG_OBJECT (pool, "%dx%d, caps %" GST_PTR_FORMAT, info.width, info.height,
caps);
if (!gst_buffer_pool_config_get_allocator (config, &allocator, &alloc_params))
goto wrong_config;
gst_caps_replace (&priv->caps, caps);
if (priv->allocator)
gst_object_unref (priv->allocator);
if (allocator) {
if (!GST_IS_D3D11_ALLOCATOR (allocator)) {
gst_object_unref (allocator);
goto wrong_allocator;
} else {
priv->allocator = gst_object_ref (allocator);
}
} else {
priv->allocator = gst_d3d11_allocator_new (priv->device);
g_assert (priv->allocator);
}
priv->add_videometa = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
if (priv->d3d11_params)
gst_d3d11_allocation_params_free (priv->d3d11_params);
priv->d3d11_params =
gst_buffer_pool_config_get_d3d11_allocation_params (config);
if (!priv->d3d11_params)
priv->d3d11_params = gst_d3d11_allocation_params_new (&alloc_params,
&info, NULL);
desc = &priv->d3d11_params->desc;
GST_LOG_OBJECT (self, "Direct3D11 Allocation params");
GST_LOG_OBJECT (self, "\t%dx%d, DXGI format %d",
desc->Width, desc->Height, desc->Format);
GST_LOG_OBJECT (self, "\tMipLevel %d, ArraySize %d",
desc->MipLevels, desc->ArraySize);
GST_LOG_OBJECT (self, "\tSampleDesc.Count %d, SampleDesc.Quality %d",
desc->SampleDesc.Count, desc->SampleDesc.Quality);
GST_LOG_OBJECT (self, "\tUsage %d", desc->Usage);
GST_LOG_OBJECT (self, "\tBindFlags 0x%x", desc->BindFlags);
GST_LOG_OBJECT (self, "\tCPUAccessFlags 0x%x", desc->CPUAccessFlags);
GST_LOG_OBJECT (self, "\tMiscFlags 0x%x", desc->MiscFlags);
max_align = alloc_params.align;
if (gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT)) {
priv->add_videometa = TRUE;
gst_buffer_pool_config_get_video_alignment (config,
&priv->d3d11_params->align);
for (n = 0; n < GST_VIDEO_MAX_PLANES; ++n)
max_align |= priv->d3d11_params->align.stride_align[n];
for (n = 0; n < GST_VIDEO_MAX_PLANES; ++n)
priv->d3d11_params->align.stride_align[n] = max_align;
gst_video_info_align (&priv->d3d11_params->info,
&priv->d3d11_params->align);
gst_buffer_pool_config_set_video_alignment (config,
&priv->d3d11_params->align);
}
if (alloc_params.align < max_align) {
GST_WARNING_OBJECT (pool, "allocation params alignment %u is smaller "
"than the max specified video stride alignment %u, fixing",
(guint) alloc_params.align, max_align);
alloc_params.align = priv->d3d11_params->parent.align = max_align;
gst_buffer_pool_config_set_allocator (config, allocator, &alloc_params);
gst_allocation_params_copy (&alloc_params);
}
gst_buffer_pool_config_set_params (config,
caps, GST_VIDEO_INFO_SIZE (&priv->d3d11_params->info), min_buffers,
max_buffers);
return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config) && ret;
/* ERRORS */
wrong_config:
{
GST_WARNING_OBJECT (pool, "invalid config");
return FALSE;
}
no_caps:
{
GST_WARNING_OBJECT (pool, "no caps in config");
return FALSE;
}
wrong_caps:
{
GST_WARNING_OBJECT (pool,
"failed getting geometry from caps %" GST_PTR_FORMAT, caps);
return FALSE;
}
wrong_allocator:
{
GST_WARNING_OBJECT (pool, "Incorrect allocator type for this pool");
return FALSE;
}
}
static GstFlowReturn
gst_d3d11_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
GstBufferPoolAcquireParams * params)
{
GstD3D11BufferPool *self = GST_D3D11_BUFFER_POOL (pool);
GstD3D11BufferPoolPrivate *priv = self->priv;
GstMemory *mem;
GstBuffer *buf;
GstVideoInfo *info = &priv->d3d11_params->info;
mem = gst_d3d11_allocator_alloc (priv->allocator, priv->d3d11_params);
if (!mem) {
GST_ERROR_OBJECT (self, "cannot create texture memory");
return GST_FLOW_ERROR;
}
buf = gst_buffer_new ();
gst_buffer_append_memory (buf, mem);
if (priv->add_videometa) {
GstD3D11Memory *dmem = (GstD3D11Memory *) mem;
GST_DEBUG_OBJECT (self, "adding GstVideoMeta");
gst_buffer_add_video_meta_full (buf, GST_VIDEO_FRAME_FLAG_NONE,
GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
GST_VIDEO_INFO_HEIGHT (info), GST_VIDEO_INFO_N_PLANES (info),
dmem->offset, dmem->stride);
}
*buffer = buf;
return GST_FLOW_OK;
}
GstD3D11BufferPool *
gst_d3d11_buffer_pool_new (GstD3D11Device * device)
{
GstD3D11BufferPool *pool;
GstD3D11Allocator *alloc;
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
pool = g_object_new (GST_TYPE_D3D11_BUFFER_POOL, NULL);
alloc = gst_d3d11_allocator_new (device);
pool->priv->device = gst_object_ref (device);
pool->priv->allocator = alloc;
return pool;
}
GstD3D11AllocationParams *
gst_buffer_pool_config_get_d3d11_allocation_params (GstStructure * config)
{
GstD3D11AllocationParams *ret;
if (!gst_structure_get (config, "d3d11-allocation-params",
GST_TYPE_D3D11_ALLOCATION_PARAMS, &ret, NULL))
ret = NULL;
return ret;
}
void
gst_buffer_pool_config_set_d3d11_allocation_params (GstStructure * config,
GstD3D11AllocationParams * params)
{
g_return_if_fail (config != NULL);
g_return_if_fail (params != NULL);
gst_structure_set (config, "d3d11-allocation-params",
GST_TYPE_D3D11_ALLOCATION_PARAMS, params, NULL);
}
/*
* GStreamer
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_D3D11_BUFFER_POOL_H__
#define __GST_D3D11_BUFFER_POOL_H__
#include <gst/gst.h>
#include <gst/video/video.h>
#include "gstd3d11_fwd.h"
G_BEGIN_DECLS
#define GST_TYPE_D3D11_BUFFER_POOL (gst_d3d11_buffer_pool_get_type())
#define GST_D3D11_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_D3D11_BUFFER_POOL, GstD3D11BufferPool))
#define GST_D3D11_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS((klass), GST_TYPE_D3D11_BUFFER_POOL, GstD3D11BufferPoolClass))
#define GST_IS_D3D11_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_D3D11_BUFFER_POOL))
#define GST_IS_D3D11_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_D3D11_BUFFER_POOL))
#define GST_D3D11_BUFFER_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_D3D11_BUFFER_POOL, GstD3D11BufferPoolClass))
struct _GstD3D11BufferPool
{
GstBufferPool parent;
/*< private >*/
GstD3D11BufferPoolPrivate *priv;
gpointer _gst_reserved[GST_PADDING];
};
struct _GstD3D11BufferPoolClass
{
GstBufferPoolClass bufferpool_class;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_d3d11_buffer_pool_get_type (void);
GstD3D11BufferPool * gst_d3d11_buffer_pool_new (GstD3D11Device *device);
GstD3D11AllocationParams * gst_buffer_pool_config_get_d3d11_allocation_params (GstStructure * config);
void gst_buffer_pool_config_set_d3d11_allocation_params (GstStructure * config,
GstD3D11AllocationParams * params);
G_END_DECLS
#endif /* __GST_D3D11_BUFFER_POOL_H__ */
This diff is collapsed.
/* GStreamer
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_D3D11_DEVICE_H__
#define __GST_D3D11_DEVICE_H__
#include <gst/gst.h>
#include <gst/video/video.h>
#include "gstd3d11_fwd.h"
G_BEGIN_DECLS
#define GST_TYPE_D3D11_DEVICE (gst_d3d11_device_get_type())
#define GST_D3D11_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_D3D11_DEVICE,GstD3D11Device))
#define GST_D3D11_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_D3D11_DEVICE,GstD3D11DeviceClass))
#define GST_D3D11_DEVICE_GET_CLASS(obj) (GST_D3D11_DEVICE_CLASS(G_OBJECT_GET_CLASS(obj)))
#define GST_IS_D3D11_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_D3D11_DEVICE))
#define GST_IS_D3D11_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_D3D11_DEVICE))
#define GST_D3D11_DEVICE_CAST(obj) ((GstD3D11Device*)(obj))
#define GST_D3D11_DEVICE_HANDLE_CONTEXT_TYPE "gst.d3d11.device.handle"
/**
* GstD3D11DeviceThreadFunc:
* @device: a #GstD3D11Device
* @data: user data
*
* Represents a function to run in the D3D11 device thread with @device and @data
*/
typedef void (*GstD3D11DeviceThreadFunc) (GstD3D11Device * device, gpointer data);
typedef enum
{
GST_D3D11_DXGI_FACTORY_UNKNOWN = 0,
GST_D3D11_DXGI_FACTORY_1,
GST_D3D11_DXGI_FACTORY_2,
GST_D3D11_DXGI_FACTORY_3,
GST_D3D11_DXGI_FACTORY_4,
GST_D3D11_DXGI_FACTORY_5,
} GstD3D11DXGIFactoryVersion;
struct _GstD3D11Device
{
GstObject parent;
GstD3D11DevicePrivate *priv;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
struct _GstD3D11DeviceClass
{
GstObjectClass parent_class;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_d3d11_device_get_type (void);
GstD3D11Device * gst_d3d11_device_new (gint adapter);
ID3D11Device * gst_d3d11_device_get_device (GstD3D11Device * device);
ID3D11DeviceContext * gst_d3d11_device_get_device_context (GstD3D11Device * device);
GstD3D11DXGIFactoryVersion gst_d3d11_device_get_chosen_dxgi_factory_version (GstD3D11Device * device);
IDXGISwapChain * gst_d3d11_device_create_swap_chain (GstD3D11Device * device,
const DXGI_SWAP_CHAIN_DESC * desc);
void gst_d3d11_device_release_swap_chain (GstD3D11Device * device,
IDXGISwapChain * swap_chain);
void gst_d3d11_device_thread_add (GstD3D11Device * device,
GstD3D11DeviceThreadFunc func,
gpointer data);
ID3D11Texture2D * gst_d3d11_device_create_texture (GstD3D11Device * device,
const D3D11_TEXTURE2D_DESC * desc,
const D3D11_SUBRESOURCE_DATA *inital_data);
void gst_d3d11_device_release_texture (GstD3D11Device * device,
ID3D11Texture2D * texture);
void gst_context_set_d3d11_device (GstContext * context,
GstD3D11Device * device);
gboolean gst_context_get_d3d11_device (GstContext * context,
GstD3D11Device ** device);
G_END_DECLS
#endif /* __GST_D3D11_DEVICE_H__ */
This diff is collapsed.
/*
* GStreamer
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_D3D11_MEMORY_H__
#define __GST_D3D11_MEMORY_H__
#include <gst/gst.h>
#include <gst/video/video.h>
#include "gstd3d11_fwd.h"
G_BEGIN_DECLS
#define GST_TYPE_D3D11_ALLOCATION_PARAMS (gst_d3d11_allocation_params_get_type())
#define GST_TYPE_D3D11_ALLOCATOR (gst_d3d11_allocator_get_type())
#define GST_D3D11_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_D3D11_ALLOCATOR, GstD3D11Allocator))
#define GST_D3D11_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS((klass), GST_TYPE_D3D11_ALLOCATOR, GstD3D11AllocatorClass))
#define GST_IS_D3D11_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_D3D11_ALLOCATOR))
#define GST_IS_D3D11_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_D3D11_ALLOCATOR))
#define GST_D3D11_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_D3D11_ALLOCATOR, GstD3D11AllocatorClass))
#define GST_D3D11_MEMORY_NAME "D3D11Memory"
/**
* GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY:
*
* Name of the caps feature for indicating the use of #GstD3D11Memory
*/
#define GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY "memory:D3D11Memory"
/**
* GST_MAP_D3D11:
*
* Flag indicating that we should map the D3D11 resource instead of to system memory.
*/
#define GST_MAP_D3D11 (GST_MAP_FLAG_LAST << 1)
struct _GstD3D11Memory
{
GstMemory mem;
GstMapFlags map_flags;
gint cpu_map_count;
ID3D11Texture2D *texture;
ID3D11Texture2D *staging;
D3D11_TEXTURE2D_DESC desc;
D3D11_MAPPED_SUBRESOURCE map;
gboolean need_upload;
gsize offset[GST_VIDEO_MAX_PLANES];
gint stride[GST_VIDEO_MAX_PLANES];
};
struct _GstD3D11AllocationParams
{
GstAllocationParams parent;
D3D11_TEXTURE2D_DESC desc;
GstVideoInfo info;
GstVideoAlignment align;
/*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE];
};
struct _GstD3D11Allocator
{
GstAllocator parent;
/*< private >*/
GstD3D11Device *device;
gpointer _gst_reserved[GST_PADDING];
};
struct _GstD3D11AllocatorClass
{
GstAllocatorClass allocator_class;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_d3d11_allocation_params_get_type (void);
GstD3D11AllocationParams * gst_d3d11_allocation_params_new (GstAllocationParams * alloc_params,
GstVideoInfo * info,
GstVideoAlignment * align);
GstD3D11AllocationParams * gst_d3d11_allocation_params_copy (GstD3D11AllocationParams * src);
void gst_d3d11_allocation_params_free (GstD3D11AllocationParams * parms);
GType gst_d3d11_allocator_get_type (void);
GstD3D11Allocator * gst_d3d11_allocator_new (GstD3D11Device *device);
GstMemory * gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator,
GstD3D11AllocationParams * params);
G_END_DECLS
#endif /* __GST_D3D11_MEMORY_H__ */
This diff is collapsed.
/* GStreamer
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_D3D11_UTILS_H__
#define __GST_D3D11_UTILS_H__
#include <gst/gst.h>
#include <gst/video/video.h>
#include "gstd3d11_fwd.h"
G_BEGIN_DECLS
GstVideoFormat gst_d3d11_dxgi_format_to_gst (DXGI_FORMAT format);
DXGI_FORMAT gst_d3d11_dxgi_format_from_gst (GstVideoFormat format);
GstCaps * gst_d3d11_device_get_supported_caps (GstD3D11Device * device,
D3D11_FORMAT_SUPPORT flags);
gboolean gst_d3d11_calculate_buffer_size (GstVideoInfo * info,
guint pitch,
gsize offset[GST_VIDEO_MAX_PLANES],
gint stride[GST_VIDEO_MAX_PLANES],
gsize *size);
gboolean gst_d3d11_handle_set_context (GstElement * element,
GstContext * context,
GstD3D11Device ** device);
gboolean gst_d3d11_handle_context_query (GstElement * element,
GstQuery * query,
GstD3D11Device * device);
gboolean gst_d3d11_ensure_element_data (GstElement * element,