2017-05-03 00:21:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Ericsson AB. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer
|
|
|
|
* in the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_NVDEC_H__
|
|
|
|
#define __GST_NVDEC_H__
|
|
|
|
|
2019-07-19 13:46:01 +00:00
|
|
|
#ifdef HAVE_NVCODEC_GST_GL
|
2017-05-03 00:21:43 +00:00
|
|
|
#include <gst/gl/gl.h>
|
2018-03-22 08:18:57 +00:00
|
|
|
#include <gst/gl/gstglfuncs.h>
|
2019-07-19 13:46:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/video/video.h>
|
nvdec,nvenc: Port to dynamic library loading
... and put them into new nvcodec plugin.
* nvcodec plugin
Now each nvenc and nvdec element is moved to be a part of nvcodec plugin
for better interoperability.
Additionally, cuda runtime API header dependencies
(i.e., cuda_runtime_api.h and cuda_gl_interop.h) are removed.
Note that cuda runtime APIs have prefix "cuda". Since 1.16 release with
Windows support, only "cuda.h" and "cudaGL.h" dependent symbols have
been used except for some defined types. However, those types could be
replaced with other types which were defined by "cuda.h".
* dynamic library loading
CUDA library will be opened with g_module_open() instead of build-time linking.
On Windows, nvcuda.dll is installed to system path by CUDA Toolkit
installer, and on *nix, user should ensure that libcuda.so.1 can be
loadable (i.e., via LD_LIBRARY_PATH or default dlopen path)
Therefore, NVIDIA_VIDEO_CODEC_SDK_PATH env build time dependency for Windows
is removed.
2019-05-17 13:27:50 +00:00
|
|
|
#include "gstcuvidloader.h"
|
|
|
|
#include "gstcudaloader.h"
|
2019-08-06 04:44:20 +00:00
|
|
|
#include "gstcudacontext.h"
|
2017-05-03 00:21:43 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
#define GST_TYPE_NVDEC (gst_nvdec_get_type())
|
|
|
|
#define GST_NVDEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_NVDEC, GstNvDec))
|
|
|
|
#define GST_NVDEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_NVDEC, GstNvDecClass))
|
2019-07-11 12:53:46 +00:00
|
|
|
#define GST_NVDEC_GET_CLASS(obj)(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_NVDEC,GstNvDecClass))
|
2017-05-03 00:21:43 +00:00
|
|
|
#define GST_IS_NVDEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_NVDEC))
|
|
|
|
#define GST_IS_NVDEC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_NVDEC))
|
|
|
|
|
|
|
|
typedef struct _GstNvDec GstNvDec;
|
|
|
|
typedef struct _GstNvDecClass GstNvDecClass;
|
|
|
|
|
2019-07-18 16:07:38 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GST_NVDEC_STATE_INIT = 0,
|
|
|
|
GST_NVDEC_STATE_PARSE,
|
|
|
|
GST_NVDEC_STATE_DECODE,
|
|
|
|
} GstNvDecState;
|
|
|
|
|
2019-07-19 13:46:01 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GST_NVDEC_MEM_TYPE_SYSTEM = 0,
|
|
|
|
GST_NVDEC_MEM_TYPE_GL,
|
|
|
|
/* FIXME: add support CUDA, D3D11 memory */
|
|
|
|
} GstNvDecMemType;
|
|
|
|
|
2017-05-03 00:21:43 +00:00
|
|
|
struct _GstNvDec
|
|
|
|
{
|
|
|
|
GstVideoDecoder parent;
|
|
|
|
|
2019-07-19 13:46:01 +00:00
|
|
|
#ifdef HAVE_NVCODEC_GST_GL
|
2017-05-03 00:21:43 +00:00
|
|
|
GstGLDisplay *gl_display;
|
|
|
|
GstGLContext *gl_context;
|
|
|
|
GstGLContext *other_gl_context;
|
2019-07-19 13:46:01 +00:00
|
|
|
#endif
|
2017-05-03 00:21:43 +00:00
|
|
|
|
|
|
|
CUvideoparser parser;
|
|
|
|
CUvideodecoder decoder;
|
2019-08-06 04:44:20 +00:00
|
|
|
GstCudaContext *cuda_ctx;
|
2019-08-18 13:07:38 +00:00
|
|
|
CUstream cuda_stream;
|
2017-05-03 00:21:43 +00:00
|
|
|
|
2019-08-09 09:47:14 +00:00
|
|
|
GstVideoInfo out_info;
|
2017-05-03 00:21:43 +00:00
|
|
|
GstClockTime min_latency;
|
|
|
|
GstVideoCodecState *input_state;
|
2019-07-24 01:00:56 +00:00
|
|
|
GstVideoCodecState *output_state;
|
2019-07-18 15:52:59 +00:00
|
|
|
|
|
|
|
GstFlowReturn last_ret;
|
2019-07-18 16:07:38 +00:00
|
|
|
GstNvDecState state;
|
2019-07-19 13:46:01 +00:00
|
|
|
GstNvDecMemType mem_type;
|
2019-08-28 14:46:44 +00:00
|
|
|
|
|
|
|
GstBuffer *codec_data;
|
2020-01-22 15:26:02 +00:00
|
|
|
gboolean recv_complete_picture;
|
2017-05-03 00:21:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstNvDecClass
|
|
|
|
{
|
|
|
|
GstVideoDecoderClass parent_class;
|
2019-07-11 12:53:46 +00:00
|
|
|
|
|
|
|
cudaVideoCodec codec_type;
|
|
|
|
guint cuda_device_id;
|
2017-05-03 00:21:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GType gst_nvdec_get_type (void);
|
|
|
|
|
2019-11-28 09:54:31 +00:00
|
|
|
void gst_nvdec_plugin_init (GstPlugin * plugin,
|
|
|
|
guint device_index,
|
2020-04-16 14:27:31 +00:00
|
|
|
cudaVideoCodec codec,
|
|
|
|
const gchar * codec_name,
|
|
|
|
GstCaps *sink_template,
|
|
|
|
GstCaps *src_template);
|
2019-07-11 12:53:46 +00:00
|
|
|
|
2017-05-03 00:21:43 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_NVDEC_H__ */
|