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