-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.h
171 lines (131 loc) · 4.53 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "sndwidget.h"
#include "audiorecorder.h"
#include "audiovizmediaplayer.h"
#include "audiovisualizerwidget.h"
#include "previewdialog.h"
#include <QMainWindow>
#include <QScopedPointer>
#include <QCloseEvent>
#include <QElapsedTimer>
#include <QMessageBox>
#include <QHBoxLayout>
#include <QFile>
#include <QFileInfo>
#include <QLineEdit>
#include <QTextEdit>
#include <QProgressBar>
#include <QVideoWidget>
#include <QGraphicsView>
#include <QGraphicsVideoItem>
#include <QMediaFormat>
#include <QMediaPlayer>
#include <QMediaRecorder>
#include <QMediaCaptureSession>
#include <QCamera>
#include <QAudioSink>
#include <QBuffer>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
QString Wakka_versione = "v1.02";
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void addVideoDisplayWidgetInDialog(); // Method to add a VideoDisplayWidget in a dialog
private slots:
void onRecorderDurationChanged(qint64 currentDuration);
void onRecorderStateChanged(QMediaRecorder::RecorderState state);
void onPlaybackStateChanged(QMediaPlayer::PlaybackState state);
void onPlayerMediaStatusChanged(QMediaPlayer::MediaStatus status);
void onPlayerPositionChanged(qint64 position);
void handleRecorderError(QMediaRecorder::Error error);
void onPreviewCheckboxToggled(bool checked);
void onVizCheckboxToggled(bool enable);
private:
QGraphicsVideoItem *webcamPreviewItem;
QGraphicsScene *webcamScene;
QGraphicsView *webcamView;
QHBoxLayout *webcamPreviewLayout;
QDialog *webcamDialog;
QColor highlightColor;
QString setRez = "1920x1080"; // its a vstack, same width, half the height
QGraphicsScene *progressScene;
QGraphicsView *progressView;
QGraphicsRectItem *progressSong = nullptr;
QGraphicsRectItem *progressSongFull = nullptr;
QGraphicsTextItem *durationTextItem;
QTimer *playbackTimer;
QElapsedTimer sysLatency;
bool isRecording = false;
bool isPlayback = false;
qint64 pos = 0;
qint64 offset = 0;
qint64 videoOffset = 0;
qint64 audioOffset = 0;
QAudioDevice selectedDevice;
QCameraDevice selectedCameraDevice;
QProgressBar *progressBar;
int totalDuration;
QVideoWidget *videoWidget;
AudioVisualizerWidget *vizUpperLeft;
AudioVisualizerWidget *vizUpperRight;
QScopedPointer<QMediaPlayer> player;
QScopedPointer<AudioVizMediaPlayer> vizPlayer;
QScopedPointer<QAudioOutput> audioOutput;
QScopedPointer<AudioRecorder> audioRecorder;
QScopedPointer<QMediaFormat> format;
QScopedPointer<QMediaRecorder> mediaRecorder;
QScopedPointer<QMediaCaptureSession> mediaCaptureSession;
QScopedPointer<QCamera> camera;
QScopedPointer<PreviewDialog> previewDialog;
QAction *loadPlaybackAction;
QAction *chooseInputAction;
QAction *singAction;
QPushButton *singButton;
QPushButton *chooseVideoButton;
QPushButton *chooseInputButton;
QPushButton *renderAgainButton;
QLabel* placeholderLabel;
QLabel *recordingIndicator;
QLabel *deviceLabel;
QLabel *banner;
QCheckBox *previewCheckbox;
QCheckBox *vizCheckbox;
// yt-dlp
QLineEdit *urlInput;
QPushButton *fetchButton;
QLabel *downloadStatusLabel;
QTextEdit *logTextEdit;
QString currentPlayback;
QString currentVideoFile;
QString currentVideoName;
QString outputFilePath;
SndWidget *soundLevelWidget;
void playVideo(const QString& playbackVideoPath);
void chooseVideo();
void updatePlaybackDuration();
void startRecording();
void stopRecording();
void handleRecordingError();
void fetchVideo();
QString millisecondsToSecondsString(qint64 milliseconds);
double getMediaDuration(const QString &filePath);
void addProgressSong(QGraphicsScene *scene, qint64 duration);
void updateProgress(const QString& output, QProgressBar* progressBar, int totalDuration);
void mixAndRender(double vocalVolume, qint64 manualOffset);
void renderAgain();
void resetMediaComponents(bool isStarting);
void configureMediaComponents();
void chooseInputDevice();
void updateDeviceLabel(const QString &deviceLabelText);
void enable_playback(bool flag);
void disconnectAllSignals();
void resizeEvent(QResizeEvent* event) override;
void closeEvent(QCloseEvent *event) override;
void logUI(const QString &msg);
void setBanner(const QString &msg);
bool eventFilter(QObject *object, QEvent *event) override;
};
#endif // MAINWINDOW_H