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 <QWidget>
22#include <QPointer>
23#include <QLocalSocket>
24#include <QLocalServer>
25#include <QDataStream>
26#include <QSharedMemory>
27#include "sharedframe.h"
28
29#include "abstractproducerwidget.h"
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, QString filename = QString(),
58 bool hideCurrentTrack = true);
59
60private slots:
61 void onConnect();
62 void onReadyRead();
63 void onSocketError(QLocalSocket::LocalSocketError socketError);
64 void onFrameDisplayed(const SharedFrame &frame);
65
66private:
67 int toMltFps(float frame) const;
68 bool copyToShared(const QImage &image);
69 SharedFrame m_sharedFrame;
70};
71
72namespace Ui {
73class GlaxnimateProducerWidget;
74}
75class QFileSystemWatcher;
76class QLocalServer;
77class QDataStream;
78class QSharedMemory;
79
80class GlaxnimateProducerWidget : public QWidget, public AbstractProducerWidget
81{
82 friend GlaxnimateIpcServer;
83
84 Q_OBJECT
85
86public:
87 explicit GlaxnimateProducerWidget(QWidget *parent = 0);
88 ~GlaxnimateProducerWidget();
89
90 // AbstractProducerWidget overrides
91 Mlt::Producer *newProducer(Mlt::Profile &);
92 virtual void setProducer(Mlt::Producer *);
93 Mlt::Properties getPreset() const;
94 void loadPreset(Mlt::Properties &);
95
96signals:
97 void producerChanged(Mlt::Producer *);
98 void modified();
99
100public slots:
101 void rename();
102
103private slots:
104 void on_colorButton_clicked();
105 void on_preset_selected(void *p);
106 void on_preset_saveClicked();
107 void on_lineEdit_editingFinished();
108 void on_notesTextEdit_textChanged();
109 void on_editButton_clicked();
110 void onFileChanged(const QString &path);
111 void on_reloadButton_clicked();
112 void on_durationSpinBox_editingFinished();
113
114private:
115 Ui::GlaxnimateProducerWidget *ui;
116 QString m_title;
117 std::unique_ptr<QFileSystemWatcher> m_watcher;
118};
119
120#endif // GLAXNIMATEPRODUCERWIDGET_H
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition sharedframe.h:49