Sayonara Player
AbstractPipeline.h
1 /* GSTPipeline.h */
2 
3 /* Copyright (C) 2011-2017 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 GSTPIPELINE_H
22 #define GSTPIPELINE_H
23 
24 #include "Utils/Settings/SayonaraClass.h"
25 #include "Utils/Pimpl.h"
26 
27 #include <gst/gst.h>
28 #include <gst/gstbuffer.h>
29 
30 #include <memory>
31 
32 #include <QTimer>
33 
34 namespace Engine
35 {
36  class Base;
37 }
38 
39 namespace Pipeline
40 {
45  enum class GSTFileMode : uint8_t
46  {
47  File,
48  Http
49  };
50 
51  bool
52  test_and_error(void* element, const QString& errorstr);
53 
54  bool
55  test_and_error_bool(bool b, const QString& errorstr);
56 
61  class Base :
62  public QObject,
63  public SayonaraClass
64  {
65  Q_OBJECT
66  PIMPL(Base)
67 
68  signals:
69  void sig_duration_changed();
70 
71  protected:
72  bool tee_connect(GstElement* tee,
73  GstPadTemplate* tee_src_pad_template,
74  GstElement* queue,
75  const QString& queue_name
76  );
77  bool create_element(GstElement** elem, const gchar* elem_name, const gchar* name="");
78 
79  virtual bool create_elements()=0;
80  virtual bool add_and_link_elements()=0;
81  virtual bool configure_elements()=0;
82 
83  virtual MilliSeconds get_about_to_finish_time() const;
84  void set_about_to_finish(bool b);
85 
86  signals:
87  void sig_finished();
88  void sig_about_to_finish(MilliSeconds ms);
89  void sig_pos_changed_ms(MilliSeconds ms);
90  void sig_data(Byte*, uint64_t);
91 
92 
93  public slots:
94  virtual void play();
95  virtual void pause();
96  virtual void stop();
97 
98 
99  public:
100  Base(QString name, Engine::Base* engine, QObject* parent=nullptr);
101  virtual ~Base();
102 
103  virtual GstElement* get_source() const=0;
104  virtual bool init(GstState state=GST_STATE_READY);
105  virtual GstElement* pipeline() const;
106  virtual GstState get_state();
107  virtual void refresh_position();
108 
109  virtual void finished();
110  virtual void check_about_to_finish();
111  virtual MilliSeconds get_time_to_go() const;
112  virtual void set_data(uchar* data, uint64_t size);
113 
114  virtual bool set_uri(gchar* uri);
115 
116  void update_duration_ms(MilliSeconds duration_ms, GstElement* src);
117  virtual MilliSeconds get_duration_ms() const final ;
118  virtual MilliSeconds get_source_position_ms() const final;
119  virtual MilliSeconds get_pipeline_position_ms() const final;
120 
121  bool has_element(GstElement* e) const;
122  };
123 }
124 
125 #endif // GSTPIPELINE_H
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
Definition: AbstractEngine.h:33
The AbstractPipeline class.
Definition: AbstractPipeline.h:61
The Engine class.
Definition: AbstractEngine.h:51
GSTFileMode
The GSTFileMode enum.
Definition: AbstractPipeline.h:45
Definition: AbstractPipeline.h:39