Debian Codegraph @

src/player.cpp

raw symbols SCIP
1 /*
2 Copyright (C) 2005-2019 Mario Stephan <[email protected]>
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "player.h"cxx . . $ `<file>/src/player.h`/
19
20 #include <QtGui>
21 #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= 0x050000
22 #include <QtConcurrent/QtConcurrent>
23 #else
24 #include <QtConcurrentRun>
25 #endif
26
27 void Playercxx . . $ Player#::sync_set_statecxx . . $ Player#sync_set_state(db0fd986d64b302f).(GstElement* element, GstState state)
28 {
29 GstStateChangeReturn res;
30 res = gst_element_set_state(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(element), state);
31 if (res == GST_STATE_CHANGE_FAILURE)
32 return;
33 if (res == GST_STATE_CHANGE_ASYNC) {
34 GstState state;
35 res = gst_element_get_state(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(element), &state, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GST_CLOCK_TIME_NONEcxx . . $ `<external>/3702184213503130145/gstclock.h:73:9`!);
36 if (res == GST_STATE_CHANGE_FAILURE || res == GST_STATE_CHANGE_ASYNC)
37 return;
38 }
39 }
40
41 void cb_newpadcxx . . $ cb_newpad(dde4ed65bff788c3).(GstElement* src,
42 GstPad* new_pad,
43 gpointer data)
44 {
45 Playercxx . . $ Player#* instance = (Playercxx . . $ Player#*)data;
46 instance->newpadcxx . . $ Player#newpad(dde4ed65bff788c3).(src, new_pad, data);
47 }
48
49 void Playercxx . . $ Player#::newpadcxx . . $ Player#newpad(dde4ed65bff788c3).(GstElement* src,
50 GstPad* new_pad,
51 gpointer data)
52 {
53 Q_UNUSEDcxx . . $ `<external>/15045578679651060896/qglobal.h:117:9`!(src);
54 Q_UNUSEDcxx . . $ `<external>/15045578679651060896/qglobal.h:117:9`!(data);
55
56 GstCaps* caps;
57 GstStructure* str;
58 GstPad* sink_pad;
59
60 /* only link once */
61 GstElement* bin = gst_bin_get_by_name(GST_BINcxx . . $ `<external>/18072804031300516349/gstbin.h:37:9`!(pipeline), "convert");
62 sink_pad = gst_element_get_static_pad(bin, "sink");
63 gst_object_unref(bin);
64
65 if (GST_PAD_IS_LINKEDcxx . . $ `<external>/7973622949010654678/gstpad.h:1036:9`!(sink_pad)) {
66 g_object_unref(sink_pad);
67 return;
68 }
69
70 /* check media type */
71 #ifdef GST_API_VERSION_1cxx . . $ `<built-in>:482:9`!
72 caps = gst_pad_query_caps(new_pad, nullptr);
73 #else
74 caps = gst_pad_get_caps(new_pad);
75 #endif
76 str = gst_caps_get_structure(caps, 0);
77 if (!g_strrstr(gst_structure_get_name(str), "audio")) {
78 gst_caps_unref(caps);
79 gst_object_unref(sink_pad);
80 return;
81 }
82 gst_caps_unref(caps);
83
84 /* link'n'play */
85 gst_pad_link(new_pad, sink_pad);
86
87 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " "
88 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "END";
89 }
90
91 struct PlayerPrivatecxx . . $ PlayerPrivate# {
92 QFutureWatchercxx . . $ QFutureWatcher#<void> watchercxx . . $ PlayerPrivate#watcher.;
93 QMutexcxx . . $ QMutex# mutexcxx . . $ PlayerPrivate#mutex.;
94 bool isStartedcxx . . $ PlayerPrivate#isStarted.;
95 bool isLoadedcxx . . $ PlayerPrivate#isLoaded.;
96 QStringcxx . . $ QString# errorcxx . . $ PlayerPrivate#error.;
97 int lengthcxx . . $ PlayerPrivate#length.;
98 int positioncxx . . $ PlayerPrivate#position.;
99 double volumecxx . . $ PlayerPrivate#volume.;
100 double rms_lcxx . . $ PlayerPrivate#rms_l.;
101 double rms_rcxx . . $ PlayerPrivate#rms_r.;
102 double rmsout_lcxx . . $ PlayerPrivate#rmsout_l.;
103 double rmsout_rcxx . . $ PlayerPrivate#rmsout_r.;
104 };
105
106 Playercxx . . $ Player#::Playercxx . . $ Player#Player(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent)
107 : QWidgetcxx . . $ QWidget#QWidget(872e7b0c281abd8d).(parent)
108 , pcxx . . $ Player#p.(new PlayerPrivatecxx . . $ PlayerPrivate#)
109 , pipelinecxx . . $ Player#pipeline.(nullptr)
110 , buscxx . . $ Player#bus.(nullptr)
111 , Gstartcxx . . $ Player#Gstart.(0)
112 , Glengthcxx . . $ Player#Glength.(0)
113 {
114 pcxx . . $ Player#p.->isStartedcxx . . $ PlayerPrivate#isStarted. = false;
115 pcxx . . $ Player#p.->isLoadedcxx . . $ PlayerPrivate#isLoaded. = false;
116
117 connectcxx . . $ QObject#connect(158df1d9a01a3410).(&pcxx . . $ Player#p.->watchercxx . . $ PlayerPrivate#watcher., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished()), this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(loadThreadFinished()));
118 }
119
120 Playercxx . . $ Player#::~cxx . . $ Player#`~Player`(ced63f7c635d850d).Playercxx . . $ Player#()
121 {
122 cleanupcxx . . $ Player#cleanup(49f6e7a06ebc5aa8).();
123 delete pcxx . . $ Player#p.;
124 pcxx . . $ Player#p. = nullptr;
125 }
126
127 GstBusSyncReply Playercxx . . $ Player#::bus_cbcxx . . $ Player#bus_cb(42d5341555275e83).(GstBus* bus, GstMessage* msg, gpointer data)
128 {
129 Q_UNUSEDcxx . . $ `<external>/15045578679651060896/qglobal.h:117:9`!(bus);
130 Playercxx . . $ Player#* instance = (Playercxx . . $ Player#*)data;
131 instance->messageReceivedcxx . . $ Player#messageReceived(5d052221dcf2e2ca).(msg);
132 return GST_BUS_PASS;
133 }
134
135 void Playercxx . . $ Player#::cleanupcxx . . $ Player#cleanup(49f6e7a06ebc5aa8).()
136 {
137 if (pipelinecxx . . $ Player#pipeline.)
138 sync_set_statecxx . . $ Player#sync_set_state(db0fd986d64b302f).(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(pipeline), GST_STATE_NULL);
139 if (buscxx . . $ Player#bus.)
140 gst_object_unref(buscxx . . $ Player#bus.);
141 if (pipelinecxx . . $ Player#pipeline.)
142 gst_object_unref(G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`!(pipeline));
143 }
144
145 bool Playercxx . . $ Player#::preparecxx . . $ Player#prepare(c9857a73d68e59ba).()
146 {
147 // Init Gst
148 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " "
149 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "START";
150 QStringcxx . . $ QString# caps_valuecxx . . $ QString#QString(ced63f7c635d850d).;
151
152 // On mac we bundle the gstreamer plugins with knowthelist
153 #if defined(Q_OS_DARWIN)
154 QString scanner_path;
155 QString plugin_path;
156 QString registry_filename;
157
158 QDir pd(QCoreApplication::applicationDirPath() + "/../plugins");
159 scanner_path = QCoreApplication::applicationDirPath() + "/../plugins/gst-plugin-scanner";
160 plugin_path = QCoreApplication::applicationDirPath() + "/../plugins/gstreamer";
161 registry_filename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QString("/gst-registry-%1-bin").arg(QCoreApplication::applicationVersion());
162
163 if (pd.exists())
164 setenv("GST_PLUGIN_SCANNER", scanner_path.toLocal8Bit().constData(), 1);
165
166 if (pd.exists()) {
167 setenv("GST_PLUGIN_PATH", plugin_path.toLocal8Bit().constData(), 1);
168 // Never load plugins from anywhere else.
169 setenv("GST_PLUGIN_SYSTEM_PATH", plugin_path.toLocal8Bit().constData(), 1);
170 }
171
172 if (!registry_filename.isEmpty()) {
173 setenv("GST_REGISTRY", registry_filename.toLocal8Bit().constData(), 1);
174 }
175 #elif defined(Q_OS_WIN32)
176 QString plugin_path = QCoreApplication::applicationDirPath() + "/plugins";
177 QDir pluginDir(plugin_path);
178 if (pluginDir.exists())
179 _putenv_s("GST_PLUGIN_PATH", plugin_path.toLocal8Bit());
180
181 #endif
182
183 //_putenv_s("GST_DEBUG", "*:4"); // win
184 //setenv("GST_DEBUG", "*:4", 1); // unix, mac
185
186 gst_init(nullptr, nullptr);
187
188 //prepare
189 GstElement *src, *conv, *resample, *sink, *gain, *vol, *level, *equalizer;
190 GstElement* levelout;
191 GstCaps* caps;
192 pipelinecxx . . $ Player#pipeline. = gst_pipeline_new("pipeline");
193 buscxx . . $ Player#bus. = gst_pipeline_get_bus(GST_PIPELINEcxx . . $ `<external>/5957108602191937761/gstpipeline.h:32:9`!(pipeline));
194
195 #ifdef GST_API_VERSION_1cxx . . $ `<built-in>:482:9`!
196 caps_value =cxx . . $ QString#`operator=`(d02845eef0c33901). "audio/x-raw";
197 #else
198 caps_value = "audio/x-raw-int";
199 #endif
200 caps = gst_caps_new_simple(caps_value.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).(),
201 "channels", G_TYPE_INTcxx . . $ `<external>/9567554376676449156/gtype.h:105:9`!, 2, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
202
203 src = gst_element_factory_make("uridecodebin", "source");
204 g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`!(src, "pad-added", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`!(cb_newpad), this);
205
206 conv = gst_element_factory_make("audioconvert", "convert");
207 resample = gst_element_factory_make("audioresample", "resample");
208 gain = gst_element_factory_make("audioamplify", "gain");
209 level = gst_element_factory_make("level", "levelintern");
210 vol = gst_element_factory_make("volume", "volume");
211 levelout = gst_element_factory_make("level", "levelout");
212 equalizer = gst_element_factory_make("equalizer-3bands", "equalizer");
213 sink = gst_element_factory_make("autoaudiosink", "sink");
214
215 g_object_set(level, "message", TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
216 g_object_set(levelout, "message", TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
217 g_object_set(level, "peak-ttl", 300000000000, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
218
219 gst_bin_add_many(GST_BINcxx . . $ `<external>/18072804031300516349/gstbin.h:37:9`!(pipeline), src, conv, resample, level, gain, equalizer, levelout, vol, sink, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
220
221 gst_element_link(conv, resample);
222 gst_element_link_filtered(resample, level, caps);
223 gst_element_link(level, gain);
224 gst_element_link(gain, equalizer);
225 gst_element_link(equalizer, vol);
226 gst_element_link_filtered(vol, levelout, caps);
227 gst_element_link(levelout, sink);
228
229 #ifdef GST_API_VERSION_1cxx . . $ `<built-in>:482:9`!
230 gst_bus_set_sync_handler(buscxx . . $ Player#bus., bus_cbcxx . . $ Player#bus_cb(42d5341555275e83)., this, nullptr);
231 #else
232 gst_bus_set_sync_handler(bus, bus_cb, this);
233 #endif
234
235 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " "
236 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "END";
237
238 return pipelinecxx . . $ Player#pipeline.;
239 }
240
241 bool Playercxx . . $ Player#::readycxx . . $ Player#ready(c9857a73d68e59ba).()
242 {
243 return pipelinecxx . . $ Player#pipeline.;
244 }
245
246 void Playercxx . . $ Player#::setGaincxx . . $ Player#setGain(ba8836b59fb42830).(double g)
247 {
248 gdouble gain_value = 1.00 * g;
249
250 GstElement* gain = gst_bin_get_by_name(GST_BINcxx . . $ `<external>/18072804031300516349/gstbin.h:37:9`!(pipeline), "gain");
251 g_object_set(G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`!(gain), "amplification", gain_value, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
252 gst_object_unref(gain);
253 }
254
255 void Playercxx . . $ Player#::setEqualizercxx . . $ Player#setEqualizer(5fbc86da912b9923).(QStringcxx . . $ QString# band, double gain)
256 {
257 gdouble gain_value = 1.00 * gain;
258
259 GstElement* equalizer = gst_bin_get_by_name(GST_BINcxx . . $ `<external>/18072804031300516349/gstbin.h:37:9`!(pipeline), "equalizer");
260 g_object_set(G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`!(equalizer), band.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).(), gain_value, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
261 gst_object_unref(equalizer);
262 }
263
264 void Playercxx . . $ Player#::opencxx . . $ Player#open(fe09fe9c2ffe9947).(QUrlcxx . . $ QUrl# url)
265 {
266 //To avoid delays load track in another thread
267 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ":" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). parentWidgetcxx . . $ QWidget#parentWidget(27f420ad5cce8994).()->objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " url=" <<cxx . . $ `operator<<`(56a6a0968dd55378). url;
268 QFuturecxx . . $ QFuture#<void> future = QtConcurrentcxx . . $ QtConcurrent/::runcxx . . $ QtConcurrent/run(99327172cea463ca).(this, &Playercxx . . $ Player#::asyncOpencxx . . $ Player#asyncOpen(fe09fe9c2ffe9947)., url);
269 pcxx . . $ Player#p.->watchercxx . . $ PlayerPrivate#watcher..setFuturecxx . . $ QFutureWatcher#setFuture(73d5e5205acf64c9).(future);
270 }
271
272 void Playercxx . . $ Player#::asyncOpencxx . . $ Player#asyncOpen(fe09fe9c2ffe9947).(QUrlcxx . . $ QUrl# url)
273 {
274 pcxx . . $ Player#p.->mutexcxx . . $ PlayerPrivate#mutex..lockcxx . . $ QMutex#lock(ced63f7c635d850d).();
275 pcxx . . $ Player#p.->lengthcxx . . $ PlayerPrivate#length. = 0;
276 pcxx . . $ Player#p.->positioncxx . . $ PlayerPrivate#position. = 0;
277 pcxx . . $ Player#p.->isLoadedcxx . . $ PlayerPrivate#isLoaded. = false;
278 pcxx . . $ Player#p.->errorcxx . . $ PlayerPrivate#error. =cxx . . $ QString#`operator=`(d02845eef0c33901). "";
279 lastErrorcxx . . $ Player#lastError. =cxx . . $ QString#`operator=`(d02845eef0c33901). "";
280
281 sync_set_statecxx . . $ Player#sync_set_state(db0fd986d64b302f).(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(pipeline), GST_STATE_NULL);
282
283 GstElement* src = gst_bin_get_by_name(GST_BINcxx . . $ `<external>/18072804031300516349/gstbin.h:37:9`!(pipeline), "source");
284 g_object_set(G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`!(src), "uri", (const char*)url.toStringcxx . . $ QUrl#toString(632475ebea3355f1).().toUtf8cxx . . $ QString#toUtf8(7c2073558a834e49).(), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
285
286 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ":" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). parentWidgetcxx . . $ QWidget#parentWidget(27f420ad5cce8994).()->objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).();
287
288 sync_set_statecxx . . $ Player#sync_set_state(db0fd986d64b302f).(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(pipeline), GST_STATE_PAUSED);
289 setPositioncxx . . $ Player#setPosition(c7ea15d6df5a9ba6).(QTimecxx . . $ QTime#QTime(748afa4755bc9595).(0, 0));
290
291 gst_object_unref(src);
292 pcxx . . $ Player#p.->mutexcxx . . $ PlayerPrivate#mutex..unlockcxx . . $ QMutex#unlock(ced63f7c635d850d).();
293 }
294
295 void Playercxx . . $ Player#::loadThreadFinishedcxx . . $ Player#loadThreadFinished(49f6e7a06ebc5aa8).()
296 {
297 // async load in player done
298 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ":" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). parentWidgetcxx . . $ QWidget#parentWidget(27f420ad5cce8994).()->objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).();
299
300 pcxx . . $ Player#p.->isLoadedcxx . . $ PlayerPrivate#isLoaded. = true;
301 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! loadFinishedcxx . . $ Player#loadFinished(49f6e7a06ebc5aa8).();
302
303 if (pcxx . . $ Player#p.->isStartedcxx . . $ PlayerPrivate#isStarted.) {
304 playcxx . . $ Player#play(49f6e7a06ebc5aa8).();
305 }
306 }
307
308 void Playercxx . . $ Player#::playcxx . . $ Player#play(49f6e7a06ebc5aa8).()
309 {
310 pcxx . . $ Player#p.->isStartedcxx . . $ PlayerPrivate#isStarted. = true;
311 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ":" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). parentWidgetcxx . . $ QWidget#parentWidget(27f420ad5cce8994).()->objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).();
312 if (pcxx . . $ Player#p.->isLoadedcxx . . $ PlayerPrivate#isLoaded.) {
313 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ":" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). parentWidgetcxx . . $ QWidget#parentWidget(27f420ad5cce8994).()->objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " call GST_STATE_PLAYING";
314 gst_element_set_state(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(pipeline), GST_STATE_PLAYING);
315 } else {
316 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ":" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). parentWidgetcxx . . $ QWidget#parentWidget(27f420ad5cce8994).()->objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " is not loaded";
317 }
318 }
319 void Playercxx . . $ Player#::stopcxx . . $ Player#stop(49f6e7a06ebc5aa8).()
320 {
321 pcxx . . $ Player#p.->isStartedcxx . . $ PlayerPrivate#isStarted. = false;
322 gst_element_set_state(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(pipeline), GST_STATE_READY);
323 }
324
325 void Playercxx . . $ Player#::pausecxx . . $ Player#pause(49f6e7a06ebc5aa8).()
326 {
327 if (isPlayingcxx . . $ Player#isPlaying(c9857a73d68e59ba).()) {
328 pcxx . . $ Player#p.->isStartedcxx . . $ PlayerPrivate#isStarted. = false;
329 gst_element_set_state(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(pipeline), GST_STATE_PAUSED);
330 }
331 }
332
333 bool Playercxx . . $ Player#::closecxx . . $ Player#close(c9857a73d68e59ba).()
334 {
335 gst_element_set_state(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(pipeline), GST_STATE_NULL);
336 return true;
337 }
338
339 void Playercxx . . $ Player#::setPositioncxx . . $ Player#setPosition(c7ea15d6df5a9ba6).(QTimecxx . . $ QTime# position)
340 {
341 int time_milliseconds = QTimecxx . . $ QTime#QTime(748afa4755bc9595).(0, 0).msecsTocxx . . $ QTime#msecsTo(f0e9a70846cde960).(position);
342 gint64 time_nanoseconds = (time_milliseconds * GST_MSECONDcxx . . $ `<external>/3702184213503130145/gstclock.h:109:9`!);
343 gst_element_seek(pipelinecxx . . $ Player#pipeline., 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
344 GST_SEEK_TYPE_SET, time_nanoseconds,
345 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONEcxx . . $ `<external>/3702184213503130145/gstclock.h:73:9`!);
346 pcxx . . $ Player#p.->positioncxx . . $ PlayerPrivate#position. = time_milliseconds;
347 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! positionChangedcxx . . $ Player#positionChanged(49f6e7a06ebc5aa8).();
348 }
349
350 QTimecxx . . $ QTime# Playercxx . . $ Player#::positioncxx . . $ Player#position(bd2fc2b92108c576).()
351 {
352 if (pipelinecxx . . $ Player#pipeline.) {
353
354 gint64 value = 0;
355
356 #ifdef GST_API_VERSION_1cxx . . $ `<built-in>:482:9`!
357 if (gst_element_query_position(pipelinecxx . . $ Player#pipeline., GST_FORMAT_TIME, &value)) {
358 #else
359 GstFormat fmt = GST_FORMAT_TIME;
360 if (gst_element_query_position(pipeline, &fmt, &value)) {
361 #endif
362 pcxx . . $ Player#p.->positioncxx . . $ PlayerPrivate#position. = static_cast<int>((value / GST_MSECONDcxx . . $ `<external>/3702184213503130145/gstclock.h:109:9`!));
363 return QTimecxx . . $ QTime#QTime(748afa4755bc9595).(0, 0).addMSecscxx . . $ QTime#addMSecs(902e6118dfa1a226).(pcxx . . $ Player#p.->positioncxx . . $ PlayerPrivate#position.); // nanosec -> msec
364 }
365 return QTimecxx . . $ QTime#QTime(748afa4755bc9595).(0, 0).addMSecscxx . . $ QTime#addMSecs(902e6118dfa1a226).(pcxx . . $ Player#p.->positioncxx . . $ PlayerPrivate#position.); // nanosec -> msec
366 }
367 return QTimecxx . . $ QTime#QTime(748afa4755bc9595).(0, 0);
368 }
369
370 QTimecxx . . $ QTime# Playercxx . . $ Player#::lengthcxx . . $ Player#length(bd2fc2b92108c576).()
371 {
372 gint64 value = 0;
373
374 if (pcxx . . $ Player#p.->lengthcxx . . $ PlayerPrivate#length. == 0 && pipelinecxx . . $ Player#pipeline.) {
375
376 #ifdef GST_API_VERSION_1cxx . . $ `<built-in>:482:9`!
377 if (gst_element_query_duration(pipelinecxx . . $ Player#pipeline., GST_FORMAT_TIME, &value)) {
378 #else
379 GstFormat fmt = GST_FORMAT_TIME;
380 if (gst_element_query_duration(pipeline, &fmt, &value)) {
381 #endif
382 pcxx . . $ Player#p.->lengthcxx . . $ PlayerPrivate#length. = static_cast<int>((value / GST_MSECONDcxx . . $ `<external>/3702184213503130145/gstclock.h:109:9`!));
383 } else
384 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ": Can not get duration";
385 }
386 return QTimecxx . . $ QTime#QTime(748afa4755bc9595).(0, 0).addMSecscxx . . $ QTime#addMSecs(902e6118dfa1a226).(pcxx . . $ Player#p.->lengthcxx . . $ PlayerPrivate#length.); // nanosec -> msec
387 }
388
389 double Playercxx . . $ Player#::volumecxx . . $ Player#volume(31fa7155c10fdd13).()
390 {
391 gdouble vol = 0;
392
393 GstElement* volume = gst_bin_get_by_name(GST_BINcxx . . $ `<external>/18072804031300516349/gstbin.h:37:9`!(pipeline), "volume");
394 g_object_get(G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`!(volume), "volume", &vol, nullptr);
395 gst_object_unref(volume);
396
397 return static_cast<double>(vol);
398 }
399
400 void Playercxx . . $ Player#::setVolumecxx . . $ Player#setVolume(ba8836b59fb42830).(double v)
401 {
402 gdouble vol = static_cast<gdouble>(v);
403 if (vol < 0.001) {
404 vol = 0.001;
405 }
406
407 GstElement* volume = gst_bin_get_by_name(GST_BINcxx . . $ `<external>/18072804031300516349/gstbin.h:37:9`!(pipeline), "volume");
408 g_object_set(G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`!(volume), "volume", vol, nullptr);
409 gst_object_unref(volume);
410 }
411
412 bool Playercxx . . $ Player#::mediaPlayablecxx . . $ Player#mediaPlayable(c9857a73d68e59ba).()
413 {
414 GstState st;
415 gst_element_get_state(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(pipeline), &st, nullptr, 0);
416 //qDebug()<<gst_element_state_get_name(st);
417 return (st != GST_STATE_NULL);
418 }
419
420 bool Playercxx . . $ Player#::isPlayingcxx . . $ Player#isPlaying(c9857a73d68e59ba).()
421 {
422 GstState st;
423 gst_element_get_state(GST_ELEMENTcxx . . $ `<external>/7744406149854824820/gstelement.h:198:9`!(pipeline), &st, nullptr, 0);
424 return (st == GST_STATE_PLAYING);
425 }
426
427 double Playercxx . . $ Player#::levelLeftcxx . . $ Player#levelLeft(31fa7155c10fdd13).() { return pcxx . . $ Player#p.->rms_lcxx . . $ PlayerPrivate#rms_l.; }
428 double Playercxx . . $ Player#::levelRightcxx . . $ Player#levelRight(31fa7155c10fdd13).() { return pcxx . . $ Player#p.->rms_rcxx . . $ PlayerPrivate#rms_r.; }
429 double Playercxx . . $ Player#::levelOutLeftcxx . . $ Player#levelOutLeft(31fa7155c10fdd13).() { return pcxx . . $ Player#p.->rmsout_lcxx . . $ PlayerPrivate#rmsout_l.; }
430 double Playercxx . . $ Player#::levelOutRightcxx . . $ Player#levelOutRight(31fa7155c10fdd13).() { return pcxx . . $ Player#p.->rmsout_rcxx . . $ PlayerPrivate#rmsout_r.; }
431
432 void Playercxx . . $ Player#::messageReceivedcxx . . $ Player#messageReceived(5d052221dcf2e2ca).(GstMessage* message)
433 {
434
435 switch (GST_MESSAGE_TYPEcxx . . $ `<external>/18276506559737325656/gstmessage.h:230:9`!(message)) {
436 case GST_STATE_CHANGE_FAILURE: {
437 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ": Gstreamer error:" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). pcxx . . $ Player#p.->errorcxx . . $ PlayerPrivate#error.;
438 }
439 case GST_MESSAGE_ERROR: {
440 if (pcxx . . $ Player#p.->errorcxx . . $ PlayerPrivate#error. ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "") {
441 GError* err;
442 gchar* debug;
443 gst_message_parse_error(message, &err, &debug);
444 pcxx . . $ Player#p.->errorcxx . . $ PlayerPrivate#error. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). "Error #" +cxx . . $ operator+(c75c3ae4eb9af1a8). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(err->codecxx . . $ _GError#code.) +cxx . . $ operator+(3d22f08efddf8107). " in module " +cxx . . $ operator+(fab9b4f80031f353). QStringcxx . . $ QString#::numbercxx . . $ QString#number(da83c6b4fd8c0e98).(err->domaincxx . . $ _GError#domain.) +cxx . . $ operator+(3d22f08efddf8107). "\n" +cxx . . $ operator+(fab9b4f80031f353). QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(5ac70cc0fa2a874e).(err->messagecxx . . $ _GError#message.);
445 if (err->domaincxx . . $ _GError#domain. != GST_STREAM_ERRORcxx . . $ `<external>/12315369297432834342/gsterror.h:235:9`! && err->codecxx . . $ _GError#code. != GST_STREAM_ERROR_FAILED) {
446 pcxx . . $ Player#p.->errorcxx . . $ PlayerPrivate#error. +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "\nMay be you should install more of gstreamer plugins";
447 lastErrorcxx . . $ Player#lastError. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(5ac70cc0fa2a874e).(err->messagecxx . . $ _GError#message.);
448 }
449 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ": Gstreamer error:" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). pcxx . . $ Player#p.->errorcxx . . $ PlayerPrivate#error.;
450 g_error_free(err);
451 g_free(debug);
452 Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! errorcxx . . $ Player#error(49f6e7a06ebc5aa8).();
453 }
454 break;
455 }
456 case GST_MESSAGE_EOS: {
457 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `/usr/include/x86_64-linux-gnu/qt5/QtCore/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ":" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). parentWidgetcxx . . $ QWidget#parentWidget(27f420ad5cce8994).()->objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " End of track reached";
458 Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! finishcxx . . $ Player#finish(49f6e7a06ebc5aa8).();
459 break;
460 }
461 case GST_MESSAGE_STATE_CHANGED: {
462 GstState old_state, new_state;
463 gst_message_parse_state_changed(message, &old_state, &new_state, nullptr);
464 switch (new_state) {
465 case GST_STATE_PAUSED:
466 case GST_STATE_NULL:
467 pcxx . . $ Player#p.->rms_lcxx . . $ PlayerPrivate#rms_l. = pcxx . . $ Player#p.->rms_rcxx . . $ PlayerPrivate#rms_r. = 0;
468 pcxx . . $ Player#p.->rmsout_lcxx . . $ PlayerPrivate#rmsout_l. = pcxx . . $ Player#p.->rmsout_rcxx . . $ PlayerPrivate#rmsout_r. = 0;
469 default:
470 break;
471 }
472 break;
473 }
474
475 case GST_MESSAGE_ELEMENT: {
476 const GstStructure* s = gst_message_get_structure(message);
477 const gchar* src_name = GST_MESSAGE_SRC_NAMEcxx . . $ `<external>/18276506559737325656/gstmessage.h:278:9`!(message);
478
479 if (strcmp(src_name, "levelintern") == 0) {
480 gint channels;
481 gdouble peak_dB;
482 gdouble rms;
483 gint i;
484
485 #ifdef GST_API_VERSION_1cxx . . $ `<built-in>:482:9`!
486 const GValue* array_val;
487 GValueArray* peak_arr;
488
489 array_val = gst_structure_get_value(s, "peak");
490 peak_arr = (GValueArray*)g_value_get_boxed(array_val);
491 channels = peak_arr->n_valuescxx . . $ _GValueArray#n_values.;
492
493 for (i = 0; i < channels; ++i) {
494 peak_dB = g_value_get_double(peak_arr->valuescxx . . $ _GValueArray#values. + i);
495 #else
496 const GValue* list;
497 const GValue* value;
498
499 list = gst_structure_get_value(s, "peak");
500 channels = gst_value_list_get_size(list);
501
502 for (i = 0; i < channels; ++i) {
503 list = gst_structure_get_value(s, "peak");
504 value = gst_value_list_get_value(list, i);
505 peak_dB = g_value_get_double(value);
506 #endif
507 /* converting from dB to normal gives us a value between 0.0 and 1.0 */
508 rms = pow(10, peak_dB / 20);
509 if (i == 0)
510 pcxx . . $ Player#p.->rms_lcxx . . $ PlayerPrivate#rms_l. = rms;
511 else
512 pcxx . . $ Player#p.->rms_rcxx . . $ PlayerPrivate#rms_r. = rms;
513 }
514 }
515 if (strcmp(src_name, "levelout") == 0) {
516 gint channels;
517 gdouble peak_dB;
518 gdouble rms;
519 gint i;
520
521 #ifdef GST_API_VERSION_1cxx . . $ `<built-in>:482:9`!
522 const GValue* array_val;
523 GValueArray* peak_arr;
524
525 array_val = gst_structure_get_value(s, "peak");
526 peak_arr = (GValueArray*)g_value_get_boxed(array_val);
527 channels = peak_arr->n_valuescxx . . $ _GValueArray#n_values.;
528
529 for (i = 0; i < channels; ++i) {
530 peak_dB = g_value_get_double(peak_arr->valuescxx . . $ _GValueArray#values. + i);
531 #else
532 const GValue* list;
533 const GValue* value;
534
535 list = gst_structure_get_value(s, "peak");
536 channels = gst_value_list_get_size(list);
537
538 for (i = 0; i < channels; ++i) {
539 list = gst_structure_get_value(s, "peak");
540 value = gst_value_list_get_value(list, i);
541 peak_dB = g_value_get_double(value);
542 #endif
543
544 /* converting from dB to normal gives us a value between 0.0 and 1.0 */
545 rms = pow(10, peak_dB / 20);
546 if (i == 0)
547 pcxx . . $ Player#p.->rmsout_lcxx . . $ PlayerPrivate#rmsout_l. = rms;
548 else
549 pcxx . . $ Player#p.->rmsout_rcxx . . $ PlayerPrivate#rmsout_r. = rms;
550 }
551 }
552 } break;
553 default:
554 break;
555 }
556 }