Link the persistent preview cache and keep image preparation free of temporary files
This commit is contained in:
1 parent
e85cb022e2
commit
41d5df798e
3 files changed
+15
-5
No files matched your search
@@ -139,6 +139,13 @@ if(PkgConfig_FOUND)
|
||||
endif()
|
||||
|
||||
# Общий sender остаётся в libutun; Qt захватывает видео, FFmpeg/Opus работают в publisher workers.
|
||||
add_library(chatgui_preview_cache STATIC src/media_preview_cache.cpp)
|
||||
target_link_libraries(chatgui_preview_cache PUBLIC ${QT_LIBS} utun PRIVATE ${FFMPEG_TARGET} ${FFMPEG_LIBRARIES})
|
||||
target_include_directories(chatgui_preview_cache PRIVATE ${FFMPEG_INCLUDE_DIRS})
|
||||
if(FFMPEG_FOUND)
|
||||
target_compile_definitions(chatgui_preview_cache PRIVATE HAVE_FFMPEG)
|
||||
endif()
|
||||
|
||||
add_library(chatgui_live_video STATIC src/live_video_encoder.cpp src/call_video_encoder.cpp src/call_video_decoder.cpp)
|
||||
target_link_libraries(chatgui_live_video PUBLIC ${QT_LIBS} utun PRIVATE ${FFMPEG_TARGET} ${FFMPEG_LIBRARIES})
|
||||
target_include_directories(chatgui_live_video PRIVATE ${FFMPEG_INCLUDE_DIRS})
|
||||
@@ -434,7 +441,7 @@ if(TARGET X11::Xss)
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
message(STATUS "X11 screen saver library not found: X11 activity uses ChatGUI input")
|
||||
endif()
|
||||
target_link_libraries(vibechat PRIVATE chatgui_notifications chatgui_stream_publish)
|
||||
target_link_libraries(vibechat PRIVATE chatgui_notifications chatgui_stream_publish chatgui_preview_cache)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(vibechat PRIVATE ${QT_LIBS} rlottie::rlottie ZLIB::ZLIB OpenSSL::Crypto ZXing::ZXing utun utun_voice pthread user32 ${FFMPEG_TARGET} ${FFMPEG_LIBRARIES})
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <QTemporaryDir>
|
||||
#include <QTransform>
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
extern "C" {
|
||||
#include "video/video.h"
|
||||
#ifdef HAVE_FFMPEG
|
||||
@@ -65,7 +66,7 @@ int videoRotation(const QString& path) {
|
||||
int index = av_find_best_stream(format, AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0); int rotation = 0;
|
||||
const uint8_t* matrix = nullptr; size_t size = 0;
|
||||
if (index >= 0) {
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 60
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 61
|
||||
const auto* parameters = format->streams[index]->codecpar;
|
||||
const auto* side = av_packet_side_data_get(parameters->coded_side_data, parameters->nb_coded_side_data, AV_PKT_DATA_DISPLAYMATRIX);
|
||||
if (side) { matrix = side->data; size = side->size; }
|
||||
@@ -85,11 +86,12 @@ int videoRotation(const QString& path) {
|
||||
}
|
||||
|
||||
QImage prepare(const QString& path, Kind kind, QString& error) {
|
||||
QTemporaryDir temporary;
|
||||
std::optional<QTemporaryDir> temporary;
|
||||
QString input = path; int rotation = 0;
|
||||
if (kind == Kind::Video) {
|
||||
if (!temporary.isValid()) { error = temporary.errorString(); return {}; }
|
||||
input = temporary.filePath(QStringLiteral("first-frame.jpg"));
|
||||
temporary.emplace();
|
||||
if (!temporary->isValid()) { error = temporary->errorString(); return {}; }
|
||||
input = temporary->filePath(QStringLiteral("first-frame.jpg"));
|
||||
if (video_extract_thumbnail(path.toUtf8().constData(), input.toUtf8().constData(), MaxSide) != 0) {
|
||||
error = QStringLiteral("cannot decode first video frame"); return {};
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
#include <QStandardPaths>
|
||||
#include <QImageReader>
|
||||
#include <QDir>
|
||||
#include <QMenu>
|
||||
#include <QFileDialog>
|
||||
|
||||
Reference in new issue
Block a user