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 <QObject>
25 
26 #include "Utils/MetaData/MetaData.h"
27 #include "Utils/Settings/SayonaraClass.h"
28 #include "Utils/Pimpl.h"
29 #include "Components/Engine/gstfwd.h"
30 
31 class QImage;
32 
33 namespace Engine
34 {
39  enum class Name : int8_t
40  {
41  Undefined=-1,
42  EngineHandler=0,
43  PlaybackEngine=1,
44  ConvertEngine=2
45  };
46 
51  class Base :
52  public QObject,
53  public SayonaraClass
54  {
55  Q_OBJECT
56  PIMPL(Base)
57 
58  signals:
59  void sig_md_changed(const MetaData& md);
60  void sig_dur_changed(const MetaData& md);
61  void sig_br_changed(const MetaData& md);
62  void sig_cover_changed(const QImage& img);
63 
64  void sig_pos_changed_ms(MilliSeconds pos_ms);
65  void sig_buffering(int progress);
66 
67  void sig_track_ready();
68  void sig_track_almost_finished(MilliSeconds time2go);
69  void sig_track_finished();
70 
71  void sig_error(const QString& message);
72 
73 
74  public:
75  explicit Base(Name name, QObject* parent=nullptr);
76  virtual ~Base();
77 
78  virtual Name name() const final;
79 
80  virtual bool init()=0;
81 
82  virtual void update_metadata(const MetaData& md, GstElement* src);
83  virtual void update_cover(const QImage& img, GstElement* src);
84  virtual void update_duration(MilliSeconds duration_ms, GstElement* src);
85  virtual void update_bitrate(Bitrate br, GstElement* src);
86 
87  virtual void set_track_ready(GstElement* src);
88  virtual void set_track_almost_finished(MilliSeconds time2go);
89  virtual void set_track_finished(GstElement* src);
90 
91  virtual void set_buffer_state(int percent, GstElement* src);
92 
93  virtual bool change_track(const MetaData& md);
94  virtual bool change_track_by_filename(const QString& filepath);
95 
96 
97  public slots:
98  virtual void play()=0;
99  virtual void stop();
100  virtual void pause()=0;
101  virtual void error(const QString& error);
102 
103  virtual void jump_abs_ms(MilliSeconds ms)=0;
104  virtual void jump_rel_ms(MilliSeconds ms)=0;
105  virtual void jump_rel(double ms)=0;
106 
107 
108  protected:
109  virtual bool change_uri(char* uri)=0;
110 
111  // if the current track is changed, this routine should be called within the
112  // change_track method. This method has to be called explicitly, because its
113  // position within the change_track method is too specific
114  virtual bool change_metadata(const MetaData& md);
115 
116  const MetaData& metadata() const;
117 
118  void set_current_position_ms(MilliSeconds pos_ms);
119  MilliSeconds current_position_ms() const;
120  };
121 }
122 
123 #endif
124 
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
The MetaData class.
Definition: MetaData.h:48
Definition: AbstractEngine.h:33
The Engine class.
Definition: AbstractEngine.h:51
Name
The EngineName enum.
Definition: AbstractEngine.h:39