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 
27 #include "Helper/Settings/SayonaraClass.h"
28 
29 #include <QTimer>
30 #include <gst/gst.h>
31 #include <gst/gstbuffer.h>
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;
46 class AbstractPipeline : public QObject, protected SayonaraClass {
47 
48  Q_OBJECT
49 
50  private:
51  bool _about_to_finish;
52  bool _initialized;
53  Engine* _engine=nullptr;
54 
55 
56  protected:
57 
58  QString _name;
59 
60  GstBus* _bus=nullptr;
61  GstElement* _pipeline=nullptr;
62  gchar* _uri=nullptr;
63 
64  qint64 _duration_ms;
65  qint64 _position_ms;
66 
67 
68  virtual bool create_element(GstElement** elem, const gchar* elem_name, const gchar* name="");
69  virtual bool create_elements()=0;
70  virtual bool add_and_link_elements()=0;
71  virtual bool configure_elements()=0;
72 
73  signals:
74  void sig_finished();
75  void sig_about_to_finish(qint64);
76  void sig_pos_changed_ms(qint64);
77  void sig_data(uchar*, quint64);
78 
79 
80  public slots:
81  virtual void play()=0;
82  virtual void pause()=0;
83  virtual void stop()=0;
84 
85  virtual qint64 get_duration_ms() final;
86  virtual qint64 get_position_ms() final;
87  virtual void set_speed(float f);
88 
89 
90  public:
91  AbstractPipeline(QString name, Engine* engine, QObject* parent=nullptr);
92  virtual ~AbstractPipeline();
93 
94  virtual GstElement* get_source() const=0;
95  virtual bool init(GstState state=GST_STATE_READY);
96  virtual GstElement* get_pipeline();
97  virtual GstBus* get_bus();
98  virtual GstState get_state();
99  virtual void refresh_position();
100  virtual void refresh_duration();
101  virtual void finished();
102  virtual void check_about_to_finish();
103  virtual qint64 get_time_to_go() const;
104  virtual void set_data(uchar* data, quint64 size);
105 
106  virtual bool set_uri(gchar* uri);
107  virtual gchar* get_uri();
108 };
109 
110 
111 #endif // GSTPIPELINE_H
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:31
Definition: AbstractEngine.h:38
Definition: AbstractPipeline.h:46