Sayonara Player
AbstractEngine.h
1 /* Engine.h */
2 
3 /* Copyright (C) 2012 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 ENGINE_H_
22 #define ENGINE_H_
23 
24 #include "Helper/Settings/SayonaraClass.h"
25 #include "Helper/MetaData/MetaData.h"
26 #include <QObject>
27 
28 #include <gst/gst.h>
29 
30 #define PLAYBACK_ENGINE "playback_engine"
31 #define CONVERT_ENGINE "convert_engine"
32 
33 class QImage;
38 enum class EngineName : quint8
39 {
40  Undefined=0,
43 };
44 
49 class Engine :
50  public QObject,
51  protected SayonaraClass
52 {
53  Q_OBJECT
54 
55 public:
56 
57  explicit Engine(QObject* parent=nullptr);
58  virtual ~Engine();
59  virtual EngineName get_name() const final;
60 
61  virtual bool init()=0;
62 
63  virtual void set_track_finished(GstElement* src);
64 
65  virtual void update_md(const MetaData& md, GstElement* src);
66  virtual void update_cover(const QImage& img, GstElement* src);
67  virtual void update_duration(GstElement* src);
68  virtual void update_bitrate(quint32 br, GstElement* src);
69 
70  virtual void set_track_ready(GstElement* src);
71  virtual void set_buffer_state(int percent, GstElement* src);
72 
73  void set_level(float right, float left);
74  void set_spectrum(QList<float>& lst );
75 
76 
77 signals:
78  void sig_md_changed(const MetaData&);
79  void sig_dur_changed(const MetaData&);
80  void sig_br_changed(const MetaData&);
81 
82  void sig_pos_changed_ms(quint64);
83  void sig_pos_changed_s(quint32);
84 
85  void sig_buffering(int progress);
86 
87  void sig_track_ready();
88  void sig_track_finished();
89 
90  void sig_download_progress(int);
91  void sig_cover_changed(const QImage& img);
92 
93 
94 protected slots:
95 
96  virtual void set_about_to_finish(qint64 ms);
97  virtual void set_cur_position_ms(qint64 ms);
98 
99 
100 public slots:
101  virtual void play()=0;
102  virtual void stop()=0;
103  virtual void pause()=0;
104 
105  virtual void jump_abs_ms(quint64 ms)=0;
106  virtual void jump_rel_ms(quint64 ms)=0;
107  virtual void jump_rel(double ms)=0;
108 
109  virtual void change_track(const MetaData&)=0;
110  virtual void change_track(const QString&)=0;
111 
112 protected:
113 
114  EngineName _name;
115  char* _uri=nullptr;
116 
117  MetaData _md;
118  qint64 _cur_pos_ms;
119  bool _playing_stream;
120  bool _broadcast_active;
121 };
122 
123 extern Engine* gst_obj_ref;
124 
125 #endif
126 
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
The MetaData class MetaDataHelper.
Definition: MetaData.h:55
The Engine class.
Definition: AbstractEngine.h:49
EngineName
The EngineName enum.
Definition: AbstractEngine.h:38
The PlaybackEngine class.
Definition: PlaybackEngine.h:55
Definition: ConvertEngine.h:29