• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer Intel MSDK plugin
2  * Copyright (c) 2016, Oblong Industries, Inc.
3  * Copyright (c) 2018, Intel Corporation
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 NEGLIGENCE
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 /**
34  * SECTION: plugin-msdk
35  *
36  * Since: 1.12
37  *
38  */
39 
40 #ifdef HAVE_CONFIG_H
41 #  include <config.h>
42 #endif
43 
44 #include <gst/gst.h>
45 
46 #include "gstmsdkh264dec.h"
47 #include "gstmsdkh264enc.h"
48 #include "gstmsdkh265dec.h"
49 #include "gstmsdkh265enc.h"
50 #include "gstmsdkmjpegdec.h"
51 #include "gstmsdkmjpegenc.h"
52 #include "gstmsdkmpeg2dec.h"
53 #include "gstmsdkmpeg2enc.h"
54 #include "gstmsdkvp8dec.h"
55 #ifdef USE_MSDK_VP9_ENC
56 #include "gstmsdkvp9enc.h"
57 #endif
58 #include "gstmsdkvc1dec.h"
59 #ifdef USE_MSDK_VP9_DEC
60 #include "gstmsdkvp9dec.h"
61 #endif
62 #ifdef USE_MSDK_AV1_DEC
63 #include "gstmsdkav1dec.h"
64 #endif
65 #include "gstmsdkvpp.h"
66 
67 GST_DEBUG_CATEGORY (gst_msdk_debug);
68 GST_DEBUG_CATEGORY (gst_msdkdec_debug);
69 GST_DEBUG_CATEGORY (gst_msdkenc_debug);
70 GST_DEBUG_CATEGORY (gst_msdkvpp_debug);
71 GST_DEBUG_CATEGORY (gst_msdkh264dec_debug);
72 GST_DEBUG_CATEGORY (gst_msdkh264enc_debug);
73 GST_DEBUG_CATEGORY (gst_msdkh265dec_debug);
74 GST_DEBUG_CATEGORY (gst_msdkh265enc_debug);
75 GST_DEBUG_CATEGORY (gst_msdkmjpegdec_debug);
76 GST_DEBUG_CATEGORY (gst_msdkmjpegenc_debug);
77 GST_DEBUG_CATEGORY (gst_msdkmpeg2enc_debug);
78 GST_DEBUG_CATEGORY (gst_msdkmpeg2dec_debug);
79 GST_DEBUG_CATEGORY (gst_msdkvp8dec_debug);
80 GST_DEBUG_CATEGORY (gst_msdkvc1dec_debug);
81 GST_DEBUG_CATEGORY (gst_msdkvp9dec_debug);
82 GST_DEBUG_CATEGORY (gst_msdkvp9enc_debug);
83 GST_DEBUG_CATEGORY (gst_msdkav1dec_debug);
84 
85 static void
plugin_add_dependencies(GstPlugin * plugin)86 plugin_add_dependencies (GstPlugin * plugin)
87 {
88 #ifndef _WIN32
89   const gchar *env_vars[] = { "LIBVA_DRIVER_NAME", NULL };
90   const gchar *kernel_paths[] = { "/dev/dri", NULL };
91   const gchar *kernel_names[] = { "card", "render", NULL };
92 
93   /* features get updated upon changes in /dev/dri/card* */
94   gst_plugin_add_dependency (plugin, NULL, kernel_paths, kernel_names,
95       GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX);
96 
97   /* features get updated upon changes in VA environment variables */
98   gst_plugin_add_dependency (plugin, env_vars, NULL, NULL,
99       GST_PLUGIN_DEPENDENCY_FLAG_NONE);
100 
101   /* features get updated upon changes in default VA drivers
102    * directory */
103   gst_plugin_add_dependency_simple (plugin, "LIBVA_DRIVERS_PATH",
104       VA_DRIVERS_PATH, "_drv_video.so",
105       GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX |
106       GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY);
107 #endif
108 }
109 
110 static gboolean
plugin_init(GstPlugin * plugin)111 plugin_init (GstPlugin * plugin)
112 {
113   gboolean ret;
114 
115   GST_DEBUG_CATEGORY_INIT (gst_msdk_debug, "msdk", 0, "msdk");
116   GST_DEBUG_CATEGORY_INIT (gst_msdkdec_debug, "msdkdec", 0, "msdkdec");
117   GST_DEBUG_CATEGORY_INIT (gst_msdkenc_debug, "msdkenc", 0, "msdkenc");
118   GST_DEBUG_CATEGORY_INIT (gst_msdkh264dec_debug, "msdkh264dec", 0,
119       "msdkh264dec");
120   GST_DEBUG_CATEGORY_INIT (gst_msdkh264enc_debug, "msdkh264enc", 0,
121       "msdkh264enc");
122   GST_DEBUG_CATEGORY_INIT (gst_msdkvpp_debug, "msdkvpp", 0, "msdkvpp");
123   GST_DEBUG_CATEGORY_INIT (gst_msdkh265dec_debug, "msdkh265dec", 0,
124       "msdkh265dec");
125   GST_DEBUG_CATEGORY_INIT (gst_msdkh265enc_debug, "msdkh265enc", 0,
126       "msdkh265enc");
127   GST_DEBUG_CATEGORY_INIT (gst_msdkmjpegdec_debug, "msdkmjpegdec", 0,
128       "msdkmjpegdec");
129   GST_DEBUG_CATEGORY_INIT (gst_msdkmjpegenc_debug, "msdkmjpegenc", 0,
130       "msdkmjpegenc");
131   GST_DEBUG_CATEGORY_INIT (gst_msdkmpeg2enc_debug, "msdkmpeg2enc", 0,
132       "msdkmpeg2enc");
133   GST_DEBUG_CATEGORY_INIT (gst_msdkmpeg2dec_debug, "msdkmpeg2dec", 0,
134       "msdkmpeg2dec");
135   GST_DEBUG_CATEGORY_INIT (gst_msdkvp8dec_debug, "msdkvp8dec", 0, "msdkvp8dec");
136   GST_DEBUG_CATEGORY_INIT (gst_msdkvc1dec_debug, "msdkvc1dec", 0, "msdkvc1dec");
137   GST_DEBUG_CATEGORY_INIT (gst_msdkvp9dec_debug, "msdkvp9dec", 0, "msdkvp9dec");
138   GST_DEBUG_CATEGORY_INIT (gst_msdkvp9enc_debug, "msdkvp9enc", 0, "msdkvp9enc");
139   GST_DEBUG_CATEGORY_INIT (gst_msdkav1dec_debug, "msdkav1dec", 0, "msdkav1dec");
140 
141   plugin_add_dependencies (plugin);
142 
143   if (!msdk_is_available ())
144     return TRUE;                /* return TRUE to avoid getting blacklisted */
145 
146   ret = gst_element_register (plugin, "msdkh264dec", GST_RANK_NONE,
147       GST_TYPE_MSDKH264DEC);
148 
149   ret = gst_element_register (plugin, "msdkh264enc", GST_RANK_NONE,
150       GST_TYPE_MSDKH264ENC);
151 
152   ret = gst_element_register (plugin, "msdkh265dec", GST_RANK_NONE,
153       GST_TYPE_MSDKH265DEC);
154 
155   ret = gst_element_register (plugin, "msdkh265enc", GST_RANK_NONE,
156       GST_TYPE_MSDKH265ENC);
157 
158   ret = gst_element_register (plugin, "msdkmjpegdec", GST_RANK_NONE,
159       GST_TYPE_MSDKMJPEGDEC);
160 
161   ret = gst_element_register (plugin, "msdkmjpegenc", GST_RANK_NONE,
162       GST_TYPE_MSDKMJPEGENC);
163 
164   ret = gst_element_register (plugin, "msdkmpeg2dec", GST_RANK_NONE,
165       GST_TYPE_MSDKMPEG2DEC);
166 
167   ret = gst_element_register (plugin, "msdkmpeg2enc", GST_RANK_NONE,
168       GST_TYPE_MSDKMPEG2ENC);
169 
170   ret = gst_element_register (plugin, "msdkvp8dec", GST_RANK_NONE,
171       GST_TYPE_MSDKVP8DEC);
172 
173   ret = gst_element_register (plugin, "msdkvc1dec", GST_RANK_NONE,
174       GST_TYPE_MSDKVC1DEC);
175 #ifdef USE_MSDK_VP9_DEC
176   ret = gst_element_register (plugin, "msdkvp9dec", GST_RANK_NONE,
177       GST_TYPE_MSDKVP9DEC);
178 #endif
179 #ifdef USE_MSDK_VP9_ENC
180   ret = gst_element_register (plugin, "msdkvp9enc", GST_RANK_NONE,
181       GST_TYPE_MSDKVP9ENC);
182 #endif
183 #ifdef USE_MSDK_AV1_DEC
184   ret = gst_element_register (plugin, "msdkav1dec", GST_RANK_NONE,
185       GST_TYPE_MSDKAV1DEC);
186 #endif
187   ret = gst_element_register (plugin, "msdkvpp", GST_RANK_NONE,
188       GST_TYPE_MSDKVPP);
189 
190   return ret;
191 }
192 
193 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
194     GST_VERSION_MINOR,
195     msdk,
196     "MFX API (" MFX_API_SDK ") based elements",
197     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
198