Sayonara Player
Loading...
Searching...
No Matches
Engine.h
1/* Engine.h */
2
3/* Copyright (C) 2011-2024 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef SAYONARA_PLAYBACK_ENGINE_H
22#define SAYONARA_PLAYBACK_ENGINE_H
23
24#include "Utils/typedefs.h"
25
26#include <QObject>
27
28#include <gst/gst.h>
29#include <memory>
30#include <vector>
31
32namespace Tagging
33{
34 class TagWriter;
35}
36
37namespace Util
38{
39 class FileSystem;
40}
41
42class MetaData;
43
44namespace Engine
45{
46 class LevelDataReceiver;
47 class Pipeline;
48 class SpectrumDataReceiver;
49
50 class Engine :
51 public QObject
52 {
53 Q_OBJECT
54
55 signals:
56 void sigDataAvailable(const QByteArray& data);
57 void sigSpectrumChanged();
58 void sigLevelChanged();
59
60 void sigMetadataChanged(const MetaData& md);
61 void sigDurationChanged(const MetaData& md);
62 void sigBitrateChanged(const MetaData& md);
63 void sigCoverDataAvailable(const QByteArray& data, const QString& mimetype);
64
65 void sigCurrentPositionChanged(MilliSeconds ms);
66 void sigBuffering(int progress);
67 void sigTrackFinished();
68 void sigTrackReady();
69 void sigError(const QString& error_message);
70
71 public:
72 explicit Engine(QObject* parent);
73 ~Engine() noexcept override;
74
75 Engine(const Engine& other) = delete;
76 Engine(Engine&& other) = delete;
77 Engine& operator=(const Engine& other) = delete;
78 Engine& operator=(Engine&& other) = delete;
79
80 virtual void updateBitrate(Bitrate br, GstElement* src) = 0;
81 virtual void updateDuration(GstElement* src) = 0;
82
83 virtual void setTrackReady(GstElement* src) = 0;
84 virtual void setTrackAlmostFinished(MilliSeconds time2go) = 0;
85 virtual void setTrackFinished(GstElement* src) = 0;
86
87 [[nodiscard]] virtual bool isStreamRecorderRecording() const = 0;
88 virtual void setStreamRecorderRecording(bool b) = 0;
89
90 virtual void setSpectrum(const std::vector<float>& spectrum) = 0;
91 [[nodiscard]] virtual const std::vector<float>& spectrum() const = 0;
92
93 virtual void setLevel(float left, float right) = 0;
94 [[nodiscard]] virtual QPair<float, float> level() const = 0;
95
96 virtual void setVisualizerEnabled(bool levelEnabled, bool spectrumEnabled) = 0;
97 virtual void setBroadcastEnabled(bool b) = 0;
98 virtual void setEqualizer(int band, int value) = 0;
99
100 [[nodiscard]] virtual MetaData currentTrack() const = 0;
101
102 public slots: // NOLINT(readability-redundant-access-specifiers)
103 virtual void play() = 0;
104 virtual void stop() = 0;
105 virtual void pause() = 0;
106
107 virtual void jumpAbsMs(MilliSeconds ms) = 0;
108 virtual void jumpRelMs(MilliSeconds ms) = 0;
109 virtual void jumpRel(double percent) = 0;
110 virtual void updateMetadata(const MetaData& track, GstElement* src) = 0;
111 virtual void updateCover(GstElement* src, const QByteArray& data, const QString& mimedata) = 0;
112
113 virtual bool changeTrack(const MetaData& track) = 0;
114
115 virtual void setBufferState(int progress, GstElement* src) = 0;
116 virtual void error(const QString& error, const QString& elementName) = 0;
117 };
118
119 Engine* createEngine(const std::shared_ptr<Util::FileSystem>& fileSystem,
120 const std::shared_ptr<Tagging::TagWriter>& tagWriter,
121 QObject* parent);
122}
123
124#endif /* SAYONARA_PLAYBACK_ENGINE_H */
Definition: Engine.h:52
The MetaData class.
Definition: MetaData.h:47
Definition: TagWriter.h:33
The GUI_TagEdit class.
Definition: Engine.h:33
Helper functions.
Definition: MetaTypeRegistry.h:25
Definition: typedefs.h:33