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 <QObject>
28 
29 #include <gst/gst.h>
30 #include <gst/gstbuffer.h>
31 
32 namespace Engine
33 {
34  class Base;
35 }
36 
37 namespace Pipeline
38 {
43  enum class GSTFileMode : uint8_t
44  {
45  File,
46  Http
47  };
48 
53  class Base :
54  public QObject,
55  public SayonaraClass
56  {
57  Q_OBJECT
58  PIMPL(Base)
59 
60  signals:
61  void sig_duration_changed();
62 
63  protected:
64  virtual bool create_elements()=0;
65  virtual bool add_and_link_elements()=0;
66  virtual bool configure_elements()=0;
67 
68  virtual MilliSeconds get_about_to_finish_time() const;
69  void set_about_to_finish(bool b);
70 
71  signals:
72  void sig_finished();
73  void sig_about_to_finish(MilliSeconds ms);
74  void sig_pos_changed_ms(MilliSeconds ms);
75  void sig_data(Byte*, uint64_t);
76 
77 
78  public slots:
79  virtual void play();
80  virtual void pause();
81  virtual void stop();
82 
83 
84  public:
85  Base(QString name, Engine::Base* engine, QObject* parent=nullptr);
86  virtual ~Base();
87 
88  virtual GstElement* get_source() const=0;
89  virtual bool init(GstState state=GST_STATE_READY);
90  virtual GstElement* pipeline() const;
91  virtual GstState get_state();
92  virtual void refresh_position();
93 
94  virtual void finished();
95  virtual void check_about_to_finish();
96  virtual MilliSeconds get_time_to_go() const;
97  virtual void set_data(uchar* data, uint64_t size);
98 
99  virtual bool set_uri(gchar* uri);
100 
101  void update_duration_ms(MilliSeconds duration_ms, GstElement* src);
102  virtual MilliSeconds get_duration_ms() const final ;
103  virtual MilliSeconds get_source_position_ms() const final;
104  virtual MilliSeconds get_pipeline_position_ms() const final;
105 
106  bool has_element(GstElement* e) const;
107  };
108 }
109 
110 #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:53
The Engine class.
Definition: AbstractEngine.h:51
GSTFileMode
The GSTFileMode enum.
Definition: AbstractPipeline.h:43
Definition: AbstractPipeline.h:37