Improved gstreamer support for GPU decoding in Linux

This commit is contained in:
Bruno Herbelin
2021-10-26 23:38:41 +02:00
parent ce0ac1bee1
commit 63f7cab508
4 changed files with 38 additions and 11 deletions

View File

@@ -176,11 +176,11 @@ string GstToolkit::gst_version()
#if GST_GL_HAVE_PLATFORM_GLX
// https://gstreamer.freedesktop.org/documentation/nvcodec/index.html?gi-language=c#plugin-nvcodec
const char *plugins[10] = { "omxmpeg4videodec", "omxmpeg2dec", "omxh264dec", "vdpaumpegdec",
"nvh264dec", "nvh265dec", "nvmpeg2videodec",
"nvmpeg4videodec", "nvvp8dec", "nvvp9dec"
};
const int N = 10;
const char *plugins[11] = { "omxmpeg4videodec", "omxmpeg2dec", "omxh264dec", "vdpaumpegdec",
"nvh264dec", "nvh265dec", "nvmpeg2videodec",
"nvmpeg4videodec", "nvvp8dec", "nvvp9dec", "vaapidecodebin"
};
const int N = 11;
#elif GST_GL_HAVE_PLATFORM_CGL
const char *plugins[2] = { "vtdec_hw", "vtdechw" };
const int N = 2;
@@ -229,7 +229,7 @@ std::string GstToolkit::used_gpu_decoding_plugins(GstElement *gstbin)
GstElement *e = static_cast<GstElement*>(g_value_peek_pointer(&value));
if (e) {
gchar *name = gst_element_get_name(e);
// g_print(" - %s", name);
g_print(" - %s", name);
std::string e_name(name);
g_free(name);
for (int i = 0; i < N; i++) {
@@ -247,3 +247,28 @@ std::string GstToolkit::used_gpu_decoding_plugins(GstElement *gstbin)
return found;
}
std::string GstToolkit::used_decoding_plugins(GstElement *gstbin)
{
std::string found = "";
GstIterator* it = gst_bin_iterate_recurse(GST_BIN(gstbin));
GValue value = G_VALUE_INIT;
for(GstIteratorResult r = gst_iterator_next(it, &value); r != GST_ITERATOR_DONE; r = gst_iterator_next(it, &value))
{
if ( r == GST_ITERATOR_OK )
{
GstElement *e = static_cast<GstElement*>(g_value_peek_pointer(&value));
if (e) {
gchar *name = gst_element_get_name(e);
found += std::string(name) + ", ";
}
}
g_value_unset(&value);
}
gst_iterator_free(it);
return found;
}

View File

@@ -24,6 +24,7 @@ std::string gst_version();
std::list<std::string> all_plugins();
std::list<std::string> enable_gpu_decoding_plugins(bool enable = true);
std::string used_gpu_decoding_plugins(GstElement *gstbin);
std::string used_decoding_plugins(GstElement *gstbin);
std::list<std::string> all_plugin_features(std::string pluginname);
bool has_feature (std::string name);

View File

@@ -69,7 +69,7 @@ Compile (or re-compile after pull):
**Libraries:**
- gstreamer
- gst-plugins : base, good, bad & ugly
- gst-plugins : libav, base, good, bad & ugly
- libglfw3
- libicu
@@ -77,7 +77,7 @@ Compile (or re-compile after pull):
**Ubuntu**
$ apt-get install build-essential cmake libpng-dev libglfw3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libicu-dev libgtk-3-dev
$ apt-get install build-essential cmake libpng-dev libglfw3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-libav libicu-dev libgtk-3-dev
**OSX with Brew**

View File

@@ -207,9 +207,10 @@ bool Rendering::init()
std::list<std::string> gpuplugins = GstToolkit::enable_gpu_decoding_plugins(Settings::application.render.gpu_decoding);
if (Settings::application.render.gpu_decoding) {
if (gpuplugins.size() > 0) {
Log::Info("Fond the following GPU decoding plugin(s):");
for(auto it = gpuplugins.begin(); it != gpuplugins.end(); it++)
Log::Info(" - %s", (*it).c_str());
Log::Info("Found the following GPU decoding plugin(s):");
int i = 1;
for(auto it = gpuplugins.rbegin(); it != gpuplugins.rend(); it++, ++i)
Log::Info("%d. %s", i, (*it).c_str());
}
else {
Log::Info("No GPU decoding plugin found.");