Sayonara Player
PlaybackPipeline.h
1 /* PlaybackPipeline.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 GSTPLAYBACKPIPELINE_H_
22 #define GSTPLAYBACKPIPELINE_H_
23 
24 #include <gst/app/gstappsink.h>
25 
26 #include "ChangeablePipeline.h"
27 #include "CrossFader.h"
28 #include "Components/Engine/AbstractPipeline.h"
29 
30 struct StreamRecorderData;
31 class Engine;
32 
38  public AbstractPipeline,
39  public CrossFader,
40  public ChangeablePipeline
41 {
42  Q_OBJECT
43 
44 
45 public:
46  explicit PlaybackPipeline(Engine* engine, QObject *parent=nullptr);
47  virtual ~PlaybackPipeline();
48 
49  bool init(GstState state=GST_STATE_NULL) override;
50  bool set_uri(gchar* uri) override;
51 
52  void set_n_sound_receiver(int num_sound_receiver);
53 
54  void set_current_volume(double volume) override;
55  double get_current_volume() const override;
56 
57  GstElement* get_source() const override;
58  GstElement* get_pipeline() const override;
59 
60 
61 public slots:
62  void play() override;
63  void pause() override;
64  void stop() override;
65 
66  void set_eq_band(const QString& band_name, double val);
67  void set_speed(float speed, double pitch, bool preserve_pitch);
68  void set_streamrecorder_path(const QString& session_path);
69 
70  gint64 seek_rel(double percent, gint64 ref_ns);
71  gint64 seek_abs(gint64 ns );
72 
73 
74 private:
75  int _vol;
76 
77  QString _sr_path;
78  StreamRecorderData* _sr_data=nullptr;
79 
80  GstElement* _audio_src=nullptr;
81  GstElement* _audio_convert=nullptr;
82  GstElement* _tee=nullptr;
83 
84  GstElement* _eq_queue=nullptr;
85  GstElement* _equalizer=nullptr;
86  GstElement* _speed=nullptr;
87  GstElement* _volume=nullptr;
88  GstElement* _pitch=nullptr;
89 
90  GstElement* _audio_sink=nullptr;
91 
92  GstElement* _spectrum_queue=nullptr;
93  GstElement* _spectrum=nullptr;
94  GstElement* _spectrum_sink=nullptr;
95 
96  GstElement* _level_queue=nullptr;
97  GstElement* _level=nullptr;
98  GstElement* _level_sink=nullptr;
99 
100  GstElement* _lame_queue=nullptr;
101  GstElement* _lame_converter=nullptr;
102  GstElement* _lame_resampler=nullptr;
103  GstElement* _lame=nullptr;
104  GstElement* _lame_app_sink=nullptr;
105 
106  GstElement* _file_queue=nullptr;
107  GstElement* _file_converter=nullptr;
108  GstElement* _file_sink=nullptr;
109  GstElement* _file_resampler=nullptr;
110  GstElement* _file_lame=nullptr;
111 
112  gulong _level_probe, _spectrum_probe, _lame_probe, _file_probe;
113  bool _show_level, _show_spectrum, _run_broadcast, _run_sr;
114 
115  bool _seek(gint64 ns);
116 
117 
118  bool create_elements() override;
119  bool add_and_link_elements() override;
120  bool configure_elements() override;
121  quint64 get_about_to_finish_time() const override;
122 
123  void init_equalizer();
124 
125 
126 protected slots:
127 
128  void _sl_vol_changed();
129  void _sl_show_level_changed();
130  void _sl_show_spectrum_changed();
131  void _sl_mute_changed();
132 
133  void _sl_speed_active_changed();
134  void _sl_speed_changed();
135 };
136 
137 #endif
The StreamRecorderData struct.
Definition: StreamRecorderData.h:32
The CrossFader class.
Definition: CrossFader.h:35
The Engine class.
Definition: AbstractEngine.h:49
The ChangeablePipeline class.
Definition: ChangeablePipeline.h:30
double get_current_volume() const override
get current volume of pipeline
void set_current_volume(double volume) override
set current volume of pipeline
The PlaybackPipeline class.
Definition: PlaybackPipeline.h:37
The AbstractPipeline class.
Definition: AbstractPipeline.h:54