File indexing completed on 2025-01-05 03:53:05
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2021-07-24 0007 * Description : a MJPEG frame generator. 0008 * 0009 * SPDX-FileCopyrightText: 2021-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_MJPEG_FRAME_TASK_H 0016 #define DIGIKAM_MJPEG_FRAME_TASK_H 0017 0018 // Qt includes 0019 0020 #include <QImage> 0021 #include <QByteArray> 0022 #include <QColor> 0023 #include <QPoint> 0024 #include <QFont> 0025 #include <QDateTime> 0026 0027 // Local includes 0028 0029 #include "actionthread.h" 0030 #include "mjpegserver.h" 0031 #include "mjpegstreamsettings.h" 0032 0033 using namespace Digikam; 0034 0035 namespace DigikamGenericMjpegStreamPlugin 0036 { 0037 0038 class MjpegFrameTask : public ActionJob 0039 { 0040 Q_OBJECT 0041 0042 public: 0043 0044 /** 0045 * Standard constructor using MJPEG stream settings. 0046 */ 0047 explicit MjpegFrameTask(const MjpegStreamSettings& settings); 0048 ~MjpegFrameTask(); 0049 0050 Q_SIGNALS: 0051 0052 /** 0053 * Output JPEG frames from generator thread (emitted to server thread). 0054 */ 0055 void signalFrameChanged(const QByteArray& frame); 0056 0057 private: 0058 0059 /** 0060 * Helper monvert a QImage to a byte-aaray of JPEG data file. 0061 */ 0062 QByteArray imageToJPEGArray(const QImage& frame) const; 0063 0064 /** 0065 * Load image from Preview cache from path with desired output size. 0066 */ 0067 QImage loadImageFromPreviewCache(const QString& path) const; 0068 0069 /** 0070 * Loop from separated main thread to render periodically frames for MJPEG stream. 0071 * This include transition between images and effect to render items. 0072 * Results are sent by signalFrameChanged(). 0073 */ 0074 void run(); 0075 0076 MjpegFrameTask(QObject*); 0077 0078 private: 0079 0080 class Private; 0081 Private* const d; 0082 }; 0083 0084 } // namespace DigikamGenericMjpegStreamPlugin 0085 0086 #endif // DIGIKAM_MJPEG_FRAME_TASK_H