aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-04-02 23:29:33 +0200
committerdec05eba <dec05eba@protonmail.com>2021-04-02 23:29:33 +0200
commit3ca7ed72c2f3a046e94213a8c26d80eafde9585c (patch)
tree67959bc624c4af5ad9d2e9ae805295097ca0a4ea /src/plugins
parent42ab6b1f7ad01cf87fa611b22313172a30eaff51 (diff)
FileManager: show video thumbnails, update thumbnail if name is the same but the content has changed (last modified time changed)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/FileManager.cpp5
-rw-r--r--src/plugins/Matrix.cpp29
2 files changed, 10 insertions, 24 deletions
diff --git a/src/plugins/FileManager.cpp b/src/plugins/FileManager.cpp
index f65486e..f15deae 100644
--- a/src/plugins/FileManager.cpp
+++ b/src/plugins/FileManager.cpp
@@ -1,5 +1,5 @@
#include "../../plugins/FileManager.hpp"
-#include "../../include/ImageUtils.hpp"
+#include "../../include/FileAnalyzer.hpp"
#include "../../include/QuickMedia.hpp"
namespace QuickMedia {
@@ -82,7 +82,8 @@ namespace QuickMedia {
for(auto &p : paths) {
auto body_item = BodyItem::create(p.path().filename().string());
// TODO: Check file magic number instead of extension?
- if(p.is_regular_file() && is_image_ext(get_ext(p.path()))) {
+ const char *ext = get_ext(p.path());
+ if(p.is_regular_file() && (is_image_ext(ext) || is_video_ext(ext))) {
body_item->thumbnail_is_local = true;
body_item->thumbnail_url = p.path().string();
}
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index ccae6ba..daae545 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -3205,28 +3205,13 @@ namespace QuickMedia {
char tmp_filename[] = "/tmp/quickmedia_video_frame_XXXXXX";
int tmp_file = mkstemp(tmp_filename);
if(tmp_file != -1) {
- if(video_get_first_frame(filepath.c_str(), tmp_filename)) {
- char tmp_filename_thumbnail[] = "/tmp/quickmedia_thumbnail_XXXXXX";
- int tmp_file_thumbnail = mkstemp(tmp_filename_thumbnail);
- if(tmp_file_thumbnail != -1) {
- std::string thumbnail_path;
- if(create_thumbnail(tmp_filename, tmp_filename_thumbnail, thumbnail_max_size))
- thumbnail_path = tmp_filename_thumbnail;
- else
- thumbnail_path = tmp_filename;
-
- UploadInfo upload_info_ignored; // Ignore because it wont be set anyways. Thumbnails dont have thumbnails.
- PluginResult upload_thumbnail_result = upload_file(room, thumbnail_path, thumbnail_info, upload_info_ignored, err_msg, false);
- if(upload_thumbnail_result != PluginResult::OK) {
- close(tmp_file_thumbnail);
- remove(tmp_filename_thumbnail);
- return upload_thumbnail_result;
- }
-
- close(tmp_file_thumbnail);
- remove(tmp_filename_thumbnail);
- } else {
- fprintf(stderr, "Failed to create temporary file for video thumbnail, ignoring thumbnail...\n");
+ if(video_get_first_frame(filepath.c_str(), tmp_filename, thumbnail_max_size.x, thumbnail_max_size.y)) {
+ UploadInfo upload_info_ignored; // Ignore because it wont be set anyways. Thumbnails dont have thumbnails.
+ PluginResult upload_thumbnail_result = upload_file(room, tmp_filename, thumbnail_info, upload_info_ignored, err_msg, false);
+ if(upload_thumbnail_result != PluginResult::OK) {
+ close(tmp_file);
+ remove(tmp_filename);
+ return upload_thumbnail_result;
}
} else {
fprintf(stderr, "Failed to get first frame of video, ignoring thumbnail...\n");