Sayonara Player
AbstractPipeline.h
1 /* GSTPipeline.h */
2 
3 /* Copyright (C) 2011-2016 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 
23 #ifndef GSTPIPELINE_H
24 #define GSTPIPELINE_H
25 
26 #include "Helper/Settings/SayonaraClass.h"
27 
28 #include <QTimer>
29 #include <gst/gst.h>
30 #include <gst/gstbuffer.h>
31 #include <QTimer>
32 
33 
34 enum class GSTFileMode : quint8 {
35  File,
36  Http
37 };
38 
39 bool
40 _test_and_error(void* element, QString errorstr);
41 
42 bool
43 _test_and_error_bool(bool b, QString errorstr);
44 
45 class Engine;
47  public QObject,
48  protected SayonaraClass
49 {
50 
51  Q_OBJECT
52 
53  private:
54  bool _about_to_finish;
55  bool _initialized;
56  Engine* _engine=nullptr;
57  QTimer* _progress_timer=nullptr;
58 
59  protected:
60 
61  QString _name;
62 
63  GstBus* _bus=nullptr;
64  GstElement* _pipeline=nullptr;
65  gchar* _uri=nullptr;
66 
67  qint64 _duration_ms;
68  qint64 _position_ms;
69 
70  bool tee_connect(GstElement* tee,
71  GstPadTemplate* tee_src_pad_template,
72  GstElement* queue,
73  const QString& queue_name
74  );
75  bool create_element(GstElement** elem, const gchar* elem_name, const gchar* name="");
76 
77  virtual bool create_elements()=0;
78  virtual bool add_and_link_elements()=0;
79  virtual bool configure_elements()=0;
80 
81  virtual quint64 get_about_to_finish_time() const;
82 
83  signals:
84  void sig_finished();
85  void sig_about_to_finish(qint64);
86  void sig_pos_changed_ms(qint64);
87  void sig_data(uchar*, quint64);
88 
89 
90  public slots:
91  virtual void play()=0;
92  virtual void pause()=0;
93  virtual void stop()=0;
94 
95  virtual qint64 get_duration_ms() final;
96  virtual qint64 get_position_ms() final;
97  virtual void set_speed(float f);
98 
99 
100  public:
101  AbstractPipeline(QString name, Engine* engine, QObject* parent=nullptr);
102  virtual ~AbstractPipeline();
103 
104  virtual GstElement* get_source() const=0;
105  virtual bool init(GstState state=GST_STATE_READY);
106  virtual GstElement* get_pipeline();
107  virtual GstBus* get_bus();
108  virtual GstState get_state();
109  virtual void refresh_position();
110  virtual void refresh_duration();
111  virtual void finished();
112  virtual void check_about_to_finish();
113  virtual qint64 get_time_to_go() const;
114  virtual void set_data(uchar* data, quint64 size);
115 
116  virtual bool set_uri(gchar* uri);
117  virtual gchar* get_uri();
118 
119  bool has_element(GstElement* e) const;
120 };
121 
122 
123 #endif // GSTPIPELINE_H
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:31
Definition: AbstractEngine.h:40
Definition: AbstractPipeline.h:46