• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <va/va_drmcommon.h>
40 #endif
41 
42 G_BEGIN_DECLS
43 
44 #define GST_TYPE_MSDK_CONTEXT \
45   (gst_msdk_context_get_type ())
46 #define GST_MSDK_CONTEXT(obj) \
47   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MSDK_CONTEXT, \
48       GstMsdkContext))
49 #define GST_MSDK_CONTEXT_CLASS(klass) \
50   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MSDK_CONTEXT, \
51       GstMsdkContextClass))
52 #define GST_IS_MSDK_CONTEXT(obj) \
53   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MSDK_CONTEXT))
54 #define GST_IS_MSDK_CONTEXT_CLASS(klass) \
55   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MSDK_CONTEXT))
56 #define GST_MSDK_CONTEXT_CAST(obj) ((GstMsdkContext*)(obj))
57 
58 typedef struct _GstMsdkContext GstMsdkContext;
59 typedef struct _GstMsdkContextClass GstMsdkContextClass;
60 typedef struct _GstMsdkContextPrivate GstMsdkContextPrivate;
61 
62 typedef enum {
63   GST_MSDK_JOB_DECODER = 0x01,
64   GST_MSDK_JOB_ENCODER = 0x02,
65   GST_MSDK_JOB_VPP = 0x04,
66 } GstMsdkContextJobType;
67 
68 /*
69  * GstMsdkContext:
70  */
71 struct _GstMsdkContext
72 {
73   GstObject parent_instance;
74 
75   GstMsdkContextPrivate *priv;
76 };
77 
78 /*
79  * GstMsdkContextClass:
80  */
81 struct _GstMsdkContextClass
82 {
83   GstObjectClass parent_class;
84 };
85 
86 GType gst_msdk_context_get_type (void);
87 
88 GstMsdkContext * gst_msdk_context_new (gboolean hardware, GstMsdkContextJobType job_type);
89 GstMsdkContext * gst_msdk_context_new_with_parent (GstMsdkContext * parent);
90 mfxSession gst_msdk_context_get_session (GstMsdkContext * context);
91 
92 gpointer gst_msdk_context_get_handle (GstMsdkContext * context);
93 gint gst_msdk_context_get_fd (GstMsdkContext * context);
94 
95 /* GstMsdkContext contains mfxFrameAllocResponses,
96  * if app calls MFXVideoCORE_SetFrameAllocator.
97  */
98 typedef struct _GstMsdkAllocResponse GstMsdkAllocResponse;
99 
100 struct _GstMsdkAllocResponse {
101   gint refcount;
102   mfxFrameAllocResponse response;
103   mfxFrameAllocRequest request;
104   GList *surfaces_avail;
105   GList *surfaces_used;
106   GList *surfaces_locked;
107 };
108 
109 GstMsdkAllocResponse *
110 gst_msdk_context_get_cached_alloc_responses (GstMsdkContext * context,
111     mfxFrameAllocResponse * resp);
112 
113 GstMsdkAllocResponse *
114 gst_msdk_context_get_cached_alloc_responses_by_request (GstMsdkContext * context,
115     mfxFrameAllocRequest * req);
116 
117 void
118 gst_msdk_context_add_alloc_response (GstMsdkContext * context,
119     GstMsdkAllocResponse * resp);
120 
121 gboolean
122 gst_msdk_context_remove_alloc_response (GstMsdkContext * context,
123     mfxFrameAllocResponse * resp);
124 
125 mfxFrameSurface1 *
126 gst_msdk_context_get_surface_available (GstMsdkContext * context, mfxFrameAllocResponse * resp);
127 
128 void
129 gst_msdk_context_put_surface_locked (GstMsdkContext * context, mfxFrameAllocResponse * resp, mfxFrameSurface1 * surface);
130 
131 void
132 gst_msdk_context_put_surface_available (GstMsdkContext * context, mfxFrameAllocResponse * resp, mfxFrameSurface1 * surface);
133 
134 GstMsdkContextJobType
135 gst_msdk_context_get_job_type (GstMsdkContext * context);
136 
137 void
138 gst_msdk_context_add_job_type (GstMsdkContext * context, GstMsdkContextJobType job_type);
139 
140 gint
141 gst_msdk_context_get_shared_async_depth (GstMsdkContext * context);
142 
143 void
144 gst_msdk_context_add_shared_async_depth (GstMsdkContext * context, gint async_depth);
145 
146 void
147 gst_msdk_context_set_frame_allocator (GstMsdkContext * context,
148     mfxFrameAllocator * allocator);
149 
150 G_END_DECLS
151 
152 #endif /* GST_MSDK_CONTEXT_H */
153