1 /* GStreamer Intel MSDK plugin 2 * Copyright (c) 2018, Intel Corporation 3 * Copyright (c) 2018, Igalia S.L. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * 3. Neither the name of the copyright holder nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGDECE 29 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef GST_MSDK_CONTEXT_H 34 #define GST_MSDK_CONTEXT_H 35 36 #include "msdk.h" 37 #ifndef _WIN32 38 #include <va/va.h> 39 #endif 40 41 G_BEGIN_DECLS 42 43 #define GST_TYPE_MSDK_CONTEXT \ 44 (gst_msdk_context_get_type ()) 45 #define GST_MSDK_CONTEXT(obj) \ 46 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MSDK_CONTEXT, \ 47 GstMsdkContext)) 48 #define GST_MSDK_CONTEXT_CLASS(klass) \ 49 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MSDK_CONTEXT, \ 50 GstMsdkContextClass)) 51 #define GST_IS_MSDK_CONTEXT(obj) \ 52 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MSDK_CONTEXT)) 53 #define GST_IS_MSDK_CONTEXT_CLASS(klass) \ 54 (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MSDK_CONTEXT)) 55 #define GST_MSDK_CONTEXT_CAST(obj) ((GstMsdkContext*)(obj)) 56 57 typedef struct _GstMsdkContext GstMsdkContext; 58 typedef struct _GstMsdkContextClass GstMsdkContextClass; 59 typedef struct _GstMsdkContextPrivate GstMsdkContextPrivate; 60 61 typedef enum { 62 GST_MSDK_JOB_DECODER = 0x01, 63 GST_MSDK_JOB_ENCODER = 0x02, 64 GST_MSDK_JOB_VPP = 0x04, 65 } GstMsdkContextJobType; 66 67 /* 68 * GstMsdkContext: 69 */ 70 struct _GstMsdkContext 71 { 72 GstObject parent_instance; 73 74 GstMsdkContextPrivate *priv; 75 }; 76 77 /* 78 * GstMsdkContextClass: 79 */ 80 struct _GstMsdkContextClass 81 { 82 GstObjectClass parent_class; 83 }; 84 85 GType gst_msdk_context_get_type (void); 86 87 GstMsdkContext * gst_msdk_context_new (gboolean hardware, GstMsdkContextJobType job_type); 88 GstMsdkContext * gst_msdk_context_new_with_parent (GstMsdkContext * parent); 89 mfxSession gst_msdk_context_get_session (GstMsdkContext * context); 90 91 gpointer gst_msdk_context_get_handle (GstMsdkContext * context); 92 gint gst_msdk_context_get_fd (GstMsdkContext * context); 93 94 /* GstMsdkContext contains mfxFrameAllocResponses, 95 * if app calls MFXVideoCORE_SetFrameAllocator. 96 */ 97 typedef struct _GstMsdkAllocResponse GstMsdkAllocResponse; 98 99 struct _GstMsdkAllocResponse { 100 mfxFrameAllocResponse *response; 101 mfxFrameAllocRequest request; 102 mfxMemId *mem_ids; 103 GList *surfaces_avail; 104 GList *surfaces_used; 105 GList *surfaces_locked; 106 }; 107 108 GstMsdkAllocResponse * 109 gst_msdk_context_get_cached_alloc_responses (GstMsdkContext * context, 110 mfxFrameAllocResponse * resp); 111 112 GstMsdkAllocResponse * 113 gst_msdk_context_get_cached_alloc_responses_by_request (GstMsdkContext * context, 114 mfxFrameAllocRequest * req); 115 116 void 117 gst_msdk_context_add_alloc_response (GstMsdkContext * context, 118 GstMsdkAllocResponse * resp); 119 120 gboolean 121 gst_msdk_context_remove_alloc_response (GstMsdkContext * context, 122 mfxFrameAllocResponse * resp); 123 124 mfxFrameSurface1 * 125 gst_msdk_context_get_surface_available (GstMsdkContext * context, mfxFrameAllocResponse * resp); 126 127 void 128 gst_msdk_context_put_surface_locked (GstMsdkContext * context, mfxFrameAllocResponse * resp, mfxFrameSurface1 * surface); 129 130 void 131 gst_msdk_context_put_surface_available (GstMsdkContext * context, mfxFrameAllocResponse * resp, mfxFrameSurface1 * surface); 132 133 GstMsdkContextJobType 134 gst_msdk_context_get_job_type (GstMsdkContext * context); 135 136 void 137 gst_msdk_context_add_job_type (GstMsdkContext * context, GstMsdkContextJobType job_type); 138 139 gint 140 gst_msdk_context_get_shared_async_depth (GstMsdkContext * context); 141 142 void 143 gst_msdk_context_add_shared_async_depth (GstMsdkContext * context, gint async_depth); 144 145 void 146 gst_msdk_context_set_frame_allocator (GstMsdkContext * context, 147 mfxFrameAllocator * allocator); 148 149 G_END_DECLS 150 151 #endif /* GST_MSDK_CONTEXT_H */ 152