Sayonara Player
Pipeline.h
1 /* PlaybackPipeline.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 GSTPLAYBACKPIPELINE_H_
22 #define GSTPLAYBACKPIPELINE_H_
23 
24 #include "PipelineExtensions/Changeable.h"
25 #include "PipelineExtensions/Fadeable.h"
26 #include "PipelineExtensions/DelayedPlayable.h"
27 #include "Utils/Pimpl.h"
28 
29 #include <QObject>
30 
31 namespace Engine
32 {
33  class Engine;
34 
39  class Pipeline :
40  public QObject,
44  {
45  Q_OBJECT
46  PIMPL(Pipeline)
47 
48  signals:
49  void sig_about_to_finish(MilliSeconds ms);
50  void sig_pos_changed_ms(MilliSeconds ms);
51  void sig_data(Byte* data, uint64_t size);
52 
53  public:
54  explicit Pipeline(const QString& name, QObject *parent=nullptr);
55  ~Pipeline() override;
56 
57  bool init(Engine* engine, GstState state=GST_STATE_NULL);
58  bool prepare(const QString& uri);
59 
60  void set_data(Byte* data, uint64_t size);
61  void set_internal_volume(double volume) override; // Crossfader
62  double get_internal_volume() const override; // Crossfader
63 
64  bool has_element(GstElement* e) const;
65  GstState state() const;
66 
67  void check_position();
68  void check_about_to_finish();
69 
70  void enable_visualizer(bool b);
71  void enable_broadcasting(bool b);
72 
73  void record(bool b);
74  void set_recording_path(const QString& session_path);
75 
76  MilliSeconds duration_ms() const;
77  MilliSeconds position_ms() const;
78  MilliSeconds time_to_go() const;
79 
80 
81  public slots:
82  void play() override; // Crossfader
83  void stop() override; // Crossfader
84  void pause();
85 
86  void set_equalizer_band(int band_name, int val);
87 
88  NanoSeconds seek_rel(double percent, NanoSeconds ref_ns);
89  NanoSeconds seek_abs(NanoSeconds ns );
90 
91 
92  protected slots:
93  void s_volume_changed();
94  void s_show_visualizer_changed();
95  void s_mute_changed();
96  void s_speed_active_changed();
97  void s_speed_changed();
98  void s_sink_changed();
99 
100 
101  private:
102  bool create_elements();
103  bool create_source(const QString& uri);
104  void remove_source();
105  GstElement* create_sink(const QString& name);
106 
107  bool add_and_link_elements();
108  void configure_elements();
109 
110  MilliSeconds get_about_to_finish_time() const;
111 
112  void set_position_element(GstElement* element);
113  GstElement* position_element();
114 
115  GstElement* pipeline() const override; // Changeable
116 
117  void fade_in_handler() override; // Crossfader
118  void fade_out_handler() override; // Crossfader
119  };
120 }
121 
122 #endif
The PlaybackEngine class.
Definition: Engine.h:47
The ChangeablePipeline class.
Definition: Changeable.h:32
The PlaybackPipeline class.
Definition: Pipeline.h:39
void set_internal_volume(double volume) override
set current volume of pipeline
The CrossFader class.
Definition: Fadeable.h:59
double get_internal_volume() const override
get current volume of pipeline
The DelayedPlayable class.
Definition: DelayedPlayable.h:33