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