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 PipelineFactory;
49 class SpectrumDataReceiver;
50
51 class Engine :
52 public QObject
53 {
54 Q_OBJECT
55
56 signals:
57 void sigDataAvailable(const QByteArray& data);
58 void sigSpectrumChanged();
59 void sigLevelChanged();
60
61 void sigMetadataChanged(const MetaData& md);
62 void sigDurationChanged(const MetaData& md);
63 void sigBitrateChanged(const MetaData& md);
64 void sigCoverDataAvailable(const QByteArray& data, const QString& mimetype);
65
66 void sigCurrentPositionChanged(MilliSeconds ms);
67 void sigBuffering(int progress);
68 void sigTrackFinished();
69 void sigTrackReady();
70 void sigError(const QString& error_message);
71
72 public:
73 Engine(QObject* parent);
74 ~Engine() noexcept override;
75
76 Engine(const Engine& other) = delete;
77 Engine(Engine&& other) = delete;
78 Engine& operator=(const Engine& other) = delete;
79 Engine& operator=(Engine&& other) = delete;
80
81 virtual void updateBitrate(Bitrate br, GstElement* src) = 0;
82 virtual void updateDuration(GstElement* src) = 0;
83
84 virtual void setTrackReady(GstElement* src) = 0;
85 virtual void setTrackAlmostFinished(MilliSeconds time2go) = 0;
86 virtual void setTrackFinished(GstElement* src) = 0;
87
88 [[nodiscard]] virtual bool isStreamRecorderRecording() const = 0;
89 virtual void setStreamRecorderRecording(bool b) = 0;
90
91 virtual void setSpectrum(const std::vector<float>& spectrum) = 0;
92 [[nodiscard]] virtual const std::vector<float>& spectrum() const = 0;
93
94 virtual void setLevel(float left, float right) = 0;
95 [[nodiscard]] virtual QPair<float, float> level() const = 0;
96
97 virtual void setVisualizerEnabled(bool isLevelActive, bool isSpectrumActive) = 0;
98 virtual void setBroadcastEnabled(bool b) = 0;
99 virtual void setEqualizer(int band, int value) = 0;
100
101 [[nodiscard]] virtual MetaData currentTrack() const = 0;
102
103 public slots: // NOLINT(readability-redundant-access-specifiers)
104 virtual void play() = 0;
105 virtual void stop() = 0;
106 virtual void pause() = 0;
107
108 virtual void jumpAbsMs(MilliSeconds ms) = 0;
109 virtual void jumpRelMs(MilliSeconds ms) = 0;
110 virtual void jumpRel(double percent) = 0;
111 virtual void updateMetadata(const MetaData& track, GstElement* src) = 0;
112 virtual void updateCover(GstElement* src, const QByteArray& data, const QString& mimedata) = 0;
113
114 virtual bool changeTrack(const MetaData& track) = 0;
115
116 virtual void setBufferState(int progress, GstElement* src) = 0;
117 virtual void error(const QString& error, const QString& elementName) = 0;
118 };
119
120 Engine* createEngine(const std::shared_ptr<Util::FileSystem>& fileSystem,
121 const std::shared_ptr<Tagging::TagWriter>& tagWriter,
122 const std::shared_ptr<PipelineFactory>& pipelineFactory,
123 QObject* parent);
124}
125
126#endif /* SAYONARA_PLAYBACK_ENGINE_H */
Definition Engine.h:53
Definition MetaData.h:43
Definition TagWriter.h:33
The GUI_TagEdit class.
Definition Engine.h:33
Helper functions.
Definition MetaTypeRegistry.h:25
Definition typedefs.h:33