diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-01-05 20:06:09 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-01-05 21:49:21 +0900 |
commit | 24c80a57fe1a79289f3028a81d6f8e0ac5f505fe (patch) | |
tree | 8f9ff9d31b9eaa04cc1c0b89865cd7bfb2ea1121 /lib/events/roommessageevent.cpp | |
parent | e3578b3cc6b978db1c04a1f684e1a03676c33f3b (diff) | |
download | libquotient-24c80a57fe1a79289f3028a81d6f8e0ac5f505fe.tar.gz libquotient-24c80a57fe1a79289f3028a81d6f8e0ac5f505fe.zip |
API version++; use QMediaResource from QtMultimedia (new dep) to detect m.video
resolution
The API version number should have been bumped long ago.
Diffstat (limited to 'lib/events/roommessageevent.cpp')
-rw-r--r-- | lib/events/roommessageevent.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/events/roommessageevent.cpp b/lib/events/roommessageevent.cpp index d63ae2fe..c3007fa0 100644 --- a/lib/events/roommessageevent.cpp +++ b/lib/events/roommessageevent.cpp @@ -23,6 +23,7 @@ #include <QtCore/QMimeDatabase> #include <QtCore/QFileInfo> #include <QtGui/QImageReader> +#include <QtMultimedia/QMediaResource> using namespace QMatrixClient; using namespace EventContent; @@ -102,24 +103,26 @@ TypedBase* contentFromFile(const QFileInfo& file, bool asGenericFile) auto filePath = file.absoluteFilePath(); auto localUrl = QUrl::fromLocalFile(filePath); auto mimeType = QMimeDatabase().mimeTypeForFile(file); - auto payloadSize = file.size(); if (!asGenericFile) { auto mimeTypeName = mimeType.name(); if (mimeTypeName.startsWith("image/")) - return new ImageContent(localUrl, payloadSize, mimeType, - QImageReader(filePath).size()); + return new ImageContent(localUrl, file.size(), mimeType, + QImageReader(filePath).size(), + file.fileName()); // duration can only be obtained asynchronously and can only be reliably // done by starting to play the file. Left for a future implementation. if (mimeTypeName.startsWith("video/")) - return new VideoContent(localUrl, payloadSize, mimeType); + return new VideoContent(localUrl, file.size(), mimeType, + QMediaResource(localUrl).resolution(), + file.fileName()); if (mimeTypeName.startsWith("audio/")) - return new AudioContent(localUrl, payloadSize, mimeType); - + return new AudioContent(localUrl, file.size(), mimeType, + file.fileName()); } - return new FileContent(localUrl, payloadSize, mimeType); + return new FileContent(localUrl, file.size(), mimeType, file.fileName()); } RoomMessageEvent::RoomMessageEvent(const QString& plainBody, |