CuteLogger
Fast and simple logging solution for Qt based applications
glaxnimateproducerwidget.h
1/*
2 * Copyright (c) 2022-2023 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef GLAXNIMATEPRODUCERWIDGET_H
19#define GLAXNIMATEPRODUCERWIDGET_H
20
21#include "abstractproducerwidget.h"
22#include "sharedframe.h"
23
24#include <QDataStream>
25#include <QLocalServer>
26#include <QLocalSocket>
27#include <QPointer>
28#include <QSharedMemory>
29#include <QWidget>
30
31class GlaxnimateIpcServer : public QObject
32{
33 Q_OBJECT
34
35 class ParentResources
36 {
37 public:
38 Mlt::Producer m_producer;
39 std::unique_ptr<Mlt::Profile> m_profile;
40 std::unique_ptr<Mlt::Producer> m_glaxnimateProducer;
41 int m_frameNum = -1;
42
43 void setProducer(const Mlt::Producer &producer, bool hideCurrentTrack);
44 };
45
46public:
47 std::unique_ptr<ParentResources> parent;
48 std::unique_ptr<QLocalServer> m_server;
49 std::unique_ptr<QDataStream> m_stream;
50 bool m_isProtocolValid = false;
51 std::unique_ptr<QSharedMemory> m_sharedMemory;
52 QPointer<QLocalSocket> m_socket;
53
54 static GlaxnimateIpcServer &instance();
55 static void newFile(const QString &filename, int duration);
56 void reset();
57 void launch(const Mlt::Producer &producer,
58 QString filename = QString(),
59 bool hideCurrentTrack = true);
60
61private slots:
62 void onConnect();
63 void onReadyRead();
64 void onSocketError(QLocalSocket::LocalSocketError socketError);
65 void onFrameDisplayed(const SharedFrame &frame);
66
67private:
68 int toMltFps(float frame) const;
69 bool copyToShared(const QImage &image);
70 SharedFrame m_sharedFrame;
71};
72
73namespace Ui {
74class GlaxnimateProducerWidget;
75}
76class QFileSystemWatcher;
77class QLocalServer;
78class QDataStream;
79class QSharedMemory;
80
81class GlaxnimateProducerWidget : public QWidget, public AbstractProducerWidget
82{
83 friend GlaxnimateIpcServer;
84
85 Q_OBJECT
86
87public:
88 explicit GlaxnimateProducerWidget(QWidget *parent = 0);
89 ~GlaxnimateProducerWidget();
90
91 // AbstractProducerWidget overrides
92 Mlt::Producer *newProducer(Mlt::Profile &);
93 virtual void setProducer(Mlt::Producer *);
94 Mlt::Properties getPreset() const;
95 void loadPreset(Mlt::Properties &);
96
97signals:
98 void producerChanged(Mlt::Producer *);
99 void modified();
100
101public slots:
102 void rename();
103
104private slots:
105 void on_colorButton_clicked();
106 void on_preset_selected(void *p);
107 void on_preset_saveClicked();
108 void on_lineEdit_editingFinished();
109 void on_notesTextEdit_textChanged();
110 void on_editButton_clicked();
111 void onFileChanged(const QString &path);
112 void on_reloadButton_clicked();
113 void on_durationSpinBox_editingFinished();
114
115private:
116 Ui::GlaxnimateProducerWidget *ui;
117 QString m_title;
118 std::unique_ptr<QFileSystemWatcher> m_watcher;
119};
120
121#endif // GLAXNIMATEPRODUCERWIDGET_H
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition sharedframe.h:50