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