1 /* GStreamer Intel MSDK plugin
2 * Copyright (c) 2018, Intel Corporation
3 * Copyright (c) 2018, Igalia S.L.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
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.
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.
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.
33 #ifndef GST_MSDK_CONTEXT_H
34 #define GST_MSDK_CONTEXT_H
39 #include <va/va_drmcommon.h>
41 #include <gst/d3d11/gstd3d11_fwd.h>
46 #define GST_TYPE_MSDK_CONTEXT \
47 (gst_msdk_context_get_type ())
48 #define GST_MSDK_CONTEXT(obj) \
49 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MSDK_CONTEXT, \
51 #define GST_MSDK_CONTEXT_CLASS(klass) \
52 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MSDK_CONTEXT, \
54 #define GST_IS_MSDK_CONTEXT(obj) \
55 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MSDK_CONTEXT))
56 #define GST_IS_MSDK_CONTEXT_CLASS(klass) \
57 (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MSDK_CONTEXT))
58 #define GST_MSDK_CONTEXT_CAST(obj) ((GstMsdkContext*)(obj))
60 typedef struct _GstMsdkContext GstMsdkContext;
61 typedef struct _GstMsdkContextClass GstMsdkContextClass;
62 typedef struct _GstMsdkContextPrivate GstMsdkContextPrivate;
65 GST_MSDK_JOB_DECODER = 0x01,
66 GST_MSDK_JOB_ENCODER = 0x02,
67 GST_MSDK_JOB_VPP = 0x04,
68 } GstMsdkContextJobType;
73 struct _GstMsdkContext
75 GstObject parent_instance;
77 GstMsdkContextPrivate *priv;
81 * GstMsdkContextClass:
83 struct _GstMsdkContextClass
85 GstObjectClass parent_class;
88 GType gst_msdk_context_get_type (void);
90 GstMsdkContext * gst_msdk_context_new (gboolean hardware, GstMsdkContextJobType job_type);
91 GstMsdkContext * gst_msdk_context_new_with_parent (GstMsdkContext * parent);
93 GstMsdkContext * gst_msdk_context_new_with_va_display (GstObject * display_obj,
94 gboolean hardware, GstMsdkContextJobType job_type);
96 GstMsdkContext * gst_msdk_context_new_with_d3d11_device (GstD3D11Device * device,
97 gboolean hardware, GstMsdkContextJobType job_type);
99 mfxSession gst_msdk_context_get_session (GstMsdkContext * context);
101 gpointer gst_msdk_context_get_handle (GstMsdkContext * context);
103 GstObject * gst_msdk_context_get_va_display (GstMsdkContext * context);
105 GstD3D11Device * gst_msdk_context_get_d3d11_device (GstMsdkContext * context);
108 /* GstMsdkContext contains mfxFrameAllocResponses,
109 * if app calls MFXVideoCORE_SetFrameAllocator.
111 typedef struct _GstMsdkAllocResponse GstMsdkAllocResponse;
113 struct _GstMsdkAllocResponse {
115 mfxFrameAllocResponse response;
116 mfxFrameAllocRequest request;
117 GList *surfaces_avail;
118 GList *surfaces_used;
119 GList *surfaces_locked;
122 GstMsdkAllocResponse *
123 gst_msdk_context_get_cached_alloc_responses (GstMsdkContext * context,
124 mfxFrameAllocResponse * resp);
126 GstMsdkAllocResponse *
127 gst_msdk_context_get_cached_alloc_responses_by_request (GstMsdkContext * context,
128 mfxFrameAllocRequest * req);
131 gst_msdk_context_add_alloc_response (GstMsdkContext * context,
132 GstMsdkAllocResponse * resp);
135 gst_msdk_context_remove_alloc_response (GstMsdkContext * context,
136 mfxFrameAllocResponse * resp);
139 gst_msdk_context_get_surface_available (GstMsdkContext * context, mfxFrameAllocResponse * resp);
142 gst_msdk_context_put_surface_locked (GstMsdkContext * context, mfxFrameAllocResponse * resp, mfxFrameSurface1 * surface);
145 gst_msdk_context_put_surface_available (GstMsdkContext * context, mfxFrameAllocResponse * resp, mfxFrameSurface1 * surface);
147 GstMsdkContextJobType
148 gst_msdk_context_get_job_type (GstMsdkContext * context);
151 gst_msdk_context_add_job_type (GstMsdkContext * context, GstMsdkContextJobType job_type);
154 gst_msdk_context_get_shared_async_depth (GstMsdkContext * context);
157 gst_msdk_context_add_shared_async_depth (GstMsdkContext * context, gint async_depth);
160 gst_msdk_context_set_frame_allocator (GstMsdkContext * context,
161 mfxFrameAllocator * allocator);
165 #endif /* GST_MSDK_CONTEXT_H */