aboutsummaryrefslogtreecommitdiffstats
path: root/core/imagedownloader.h
AgeCommit message (Collapse)Author
2018-07-28Dive media: Extract thumbnails from videos with ffmpegGravatar Berthold Stoeger
Extract thumbnails using ffmpeg. Behavior is controlled by three new preferences fields: - extract_video_thumbnails (bool): if true, thumbnails are calculated. - extract_video_thumbnail_position (int 0..100): position in video where thumbnail is fetched. - ffmpeg_executable (string): path of ffmpeg executable. If ffmpeg refuses to start, extract_video_thumbnails is set to false to avoid unnecessary churn. Video thumbnails are marked by an overlay. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23Dive video: paint duration-bar above thumbnail in profile plotGravatar Berthold Stoeger
Paint a rectangle on top of thumbnails indicating the run-time of the video. Use the z=100.0-101.0 range for painting the thumbnails, whereby the z-value increases uniformly from first to last thumbnail (sorted by timestamp). The duration-bars are placed at z-values midway between those of the thumbnails. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23Dive media: prepare for video-thumbnailsGravatar Berthold Stoeger
Video thumbnails are more complex than simple picture thumbnails. We store a duration and might want to store multiple images. Therefore, refactor the thumbnailing in imagedownloader.cpp. Move the thumbnail-writing down in the call chain to where the thumbnails are created, since we have more information there (i.e. whether we could parse the file but not extract an image, etc.). Split the write-to-cache function into three versions: - pictures - videos - unknown Define the video-thumbnail on-disk format as - uint32 MEDIATYPE_VIDEO - uint32 duration of video in seconds - uint32 number of pictures for each picture: - uint32 offset in msec from begining of video - QImage frame Currently, we write 0 pictures. This will be filled in subsequent commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-09Dive pictures: differentiate between IO-error and unknown formatGravatar Berthold Stoeger
Show different images for IO-error and unknow file format. Use file-extensions to recognize video files if we couldn't parse them. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-08Dive pictures: detach ProfileWidget2 from DivePictureModelGravatar Berthold Stoeger
As long as ProfileWidget2 and DivePictureModel showed the same set of pictures and any change would lead to a full recalculation of the set, it made sense to let ProfileWidget2 use DivePictureModel's data. Recently, keeping the two lists in sync become more and more of a burden. Therefore, disconnect ProfileWidget2 and DivePictureModel. This will lead to some code-duplication and perhaps a temporary drop in UI-performance, but in the end the code is distinctly simpler and also more flexible. Thus, for example the DivePhotoTab could be changed to support headings without having to touch ProfileWidget2 at all. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-08Dive pictures: Recognize video filesGravatar Berthold Stoeger
When generating thumbnails, test for video files. If it is, use a dummy-thumbnail. Write only the type (video), but no image to the thumbnail cache, for forward-compatibility. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-13Dive pictures: Make failure of loading images less noisyGravatar Berthold Stoeger
For debug reasons, failure to load the original image was spilled to the console, even if the local file was then found. Only print a message, when also the local image failed loading. This needed a bit of code reshuffling. To know when to print a failed-loading message, the URL is now checked at the Thumbnailer level, not the ImageDownloader level. The ImageDownloader is passed the URL and the original filename (if different). The image is loaded from the URL, but the signals send the original filename, so that the thumbnail can be associated to the proper image. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-27Dive pictures: give user option to recalculate thumbnailsGravatar Berthold Stoeger
Even though hashes of image contents are calculated, the hashes are not compared to actual file contents in routine-operation. Therefore give the user the option to recalculate thumbnails, should they have edited the picture. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-26Cleanup: remove code related to pictures in the cloud-repositoryGravatar Berthold Stoeger
Storing pictures in the cloud never came to be, so remove the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-18core: solved PictureEntry defined as class and struct.Gravatar jan Iversen
PictureEntry was defined as class in imagedownloader.h and as struct in divepicturemodel.h A class has a vptr in front, so the difference is real at least for the clang compiler. Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-16Dive pictures: Don't enter infinity loop on invalid picturesGravatar Berthold Stoeger
The recently committed refactoring of the dive-picture code introduced a severe bug: If an image couldn't be loaded from disk owing to an invalid file, the filename was interpreted as an url and loaded in the background. This succeeded, because the file actually exists. After download, the file would then still be invalid and the whole thing restarted, leading to an infinity loop. To fix this, do two things: 1) Don't even try to download local files. 2) If interpreting a downloaded file fails, don't try the downloading business again. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: refactor image downloaderGravatar Berthold Stoeger
Instead of generating one ImageDownloader object per image to be downloaded and running every image download in a separate worker thread, use one global ImageDownloader object owned by the UI thread. The images are downloaded using event based IO (as probably was the intention of the QNetworkManager class). User-visible change: after download from the internet, the thumbnail is shown without having to change dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Move thumbnail-size to Thumbnailer classGravatar Berthold Stoeger
The size of the to-be-created thumbnails was passed from DivePictureModel to Thumbnailer. This became more and more bothersome, because the size had to be stored with the request. Calling from Thumbnailer into DivePictureModel was not an option, since this is not linked to all tests. Therefore, move these functions to the Thumbnailer class. Since the maximum thumbnail size is now known to the thumbnailer, the dummy and failure images can be precalculated, which makes switching between dives faster. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Introduce thumbnailer classGravatar Berthold Stoeger
Create a new class, which performs all thumbnailing code. This is mostly code reshuffling. Thumbnails are extracted either from a cache or thumbnail calculation is started in a worker thread. Since getHashedImage() is called from a worker thread it makes no sense to call subfunctions in yet another worker thread. Remove these calls. In contrast to the previous code, on error the background thread produces a failure image, but it is not yet shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: replace picture struct by QStringGravatar Berthold Stoeger
In imagedownloader.cpp the only thing we need from the picture struct is the filename. Therefore, use QStrings instead of the picture struct. This simplifies memory management. Remove the clone_picture() function, which is not needed anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: turn SHashedImage class into getHashedImage() functionGravatar Berthold Stoeger
SHashedImage was a subclass of QImage, which fetched the image according to the filename hashes. Turn this into a function, as this is much more idiomatic and flexible. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-19Coding style: remove superfluous semicolonsGravatar Berthold Stoeger
Remove a semicolon after Q_OBJECT and a few others after the closing braces of while loops. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-01Debug: Error reporting for SHashedImage loadingGravatar Berthold Stoeger
Overwrite QImage::load() in SHashedImage so that we can perform better error reporting. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05core/imagedownloader.cpp: remove recursionGravatar Berthold Stoeger
If loading from hash failed in the saveImage() slot(!) it would recurse into loadFromUrl(), which would generate a new network reply. Very scary and a (small) wonder that it worked. Let's try to make this all more explicit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05core/imagedownloader.cpp: Make the manager object local to load()Gravatar Berthold Stoeger
The QNetworkAccessManager is only used in the load() function. No point in it being a subobject. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07Cleanup: remove unused typedefGravatar Berthold Stoeger
The type SHashedFilename defined in core/imagedownloader.h was not used anywhere. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07Cleanup: Make local helpers and variables of static linkageGravatar Berthold Stoeger
In core/imagedownloader.cpp the helpers cloudImageUrl() and loadPicture() are made of static linkage. The global variables queuedPictures and pictureQueueMutex were moved into the loadPicture() function, because they are used only there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-04-29Add SPDX header to remaining core filesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>