Skip to content

Commit

Permalink
feat: just use QLibrary to search .so
Browse files Browse the repository at this point in the history
Log:
When loading the library, QLibrary searches in all the system-specific library locations (e.g. LD_LIBRARY_PATH on Unix), unless the file name has an absolute path.

for linux, will use dlopen in QLibrary: https://man7.org/linux/man-pages/man3/dlopen.3.html
  • Loading branch information
wineee authored and rb-union committed Sep 5, 2023
1 parent 3205ebc commit 89bd3a0
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions libimageviewer/service/ffmpegvideothumbnailer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,9 @@ static video_thumbnailer *m_video_thumbnailer = nullptr;
//解析成功标记
static bool resolveSuccessed = false;

static QString libPath(const QString &strlib)
{
QDir dir;
QString path = QLibraryInfo::location(QLibraryInfo::LibrariesPath);
dir.setPath(path);
QStringList list = dir.entryList(QStringList() << (strlib + "*"), QDir::NoDotAndDotDot | QDir::Files); //filter name with strlib
if (list.contains(strlib)) {
return strlib;
} else {
list.sort();
}

if (list.size() > 0) {
return list.last();
} else {
return QString();
}
}

bool initFFmpegVideoThumbnailer()
{
QLibrary library(libPath("libffmpegthumbnailer.so"));
QLibrary library("libffmpegthumbnailer.so");
m_creat_video_thumbnailer = reinterpret_cast<mvideo_thumbnailer_create>(library.resolve("video_thumbnailer_create"));
m_mvideo_thumbnailer_destroy = reinterpret_cast<mvideo_thumbnailer_destroy>(library.resolve("video_thumbnailer_destroy"));
m_mvideo_thumbnailer_create_image_data = reinterpret_cast<mvideo_thumbnailer_create_image_data>(library.resolve("video_thumbnailer_create_image_data"));
Expand Down

0 comments on commit 89bd3a0

Please sign in to comment.