1 /* 2 * Copyright (C) 2017 Ericsson AB. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef __GST_NVDEC_H__ 29 #define __GST_NVDEC_H__ 30 31 #include <gst/gl/gl.h> 32 #include <gst/gl/gstglfuncs.h> 33 #include "nvcuvid.h" 34 #include <cudaGL.h> 35 36 G_BEGIN_DECLS 37 38 typedef struct _GstNvDecCudaContext GstNvDecCudaContext; 39 typedef struct _GstNvDecCudaContextClass GstNvDecCudaContextClass; 40 41 struct _GstNvDecCudaContext 42 { 43 GObject parent; 44 45 CUcontext context; 46 CUvideoctxlock lock; 47 }; 48 49 struct _GstNvDecCudaContextClass 50 { 51 GObjectClass parent_class; 52 }; 53 54 GType gst_nvdec_cuda_context_get_type (void); 55 56 57 #define GST_TYPE_NVDEC (gst_nvdec_get_type()) 58 #define GST_NVDEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_NVDEC, GstNvDec)) 59 #define GST_NVDEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_NVDEC, GstNvDecClass)) 60 #define GST_IS_NVDEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_NVDEC)) 61 #define GST_IS_NVDEC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_NVDEC)) 62 63 typedef struct _GstNvDec GstNvDec; 64 typedef struct _GstNvDecClass GstNvDecClass; 65 66 struct _GstNvDec 67 { 68 GstVideoDecoder parent; 69 70 GstGLDisplay *gl_display; 71 GstGLContext *gl_context; 72 GstGLContext *other_gl_context; 73 74 GstNvDecCudaContext *cuda_context; 75 CUvideoparser parser; 76 CUvideodecoder decoder; 77 GAsyncQueue *decode_queue; 78 79 guint width; 80 guint height; 81 guint fps_n; 82 guint fps_d; 83 GstClockTime min_latency; 84 GstVideoCodecState *input_state; 85 }; 86 87 struct _GstNvDecClass 88 { 89 GstVideoDecoderClass parent_class; 90 }; 91 92 GType gst_nvdec_get_type (void); 93 94 G_END_DECLS 95 96 #endif /* __GST_NVDEC_H__ */ 97