| 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 | #ifndef MONITORPLAYER_H |
| 19 | #define MONITORPLAYER_H |
| 20 | |
| 21 | #include <QtCore> |
| 22 | #include <QWidget> |
| 23 | |
| 24 | #if defined(Q_OS_WIN32) |
| 25 | #include <windows.h> |
| 26 | #include <dsound.h> |
| 27 | #endif |
| 28 | |
| 29 | #define GST_DISABLE_LOADSAVE 1 |
| 30 | #define GST_DISABLE_REGISTRY 1 |
| 31 | #define GST_DISABLE_DEPRECATED 1 |
| 32 | #include <gst/gst.h> |
| 33 | |
| 34 | typedef QPair<QString, QUuid> dsDevice; |
| 35 | |
| 36 | |
| 37 | class MonitorPlayer: public QWidget |
| 38 | { |
| 39 | Q_OBJECT |
| 40 | public: |
| 41 | MonitorPlayer(QWidget *parent = nullptr); |
| 42 | ~MonitorPlayer(); |
| 43 | |
| 44 | |
| 45 | bool prepare(); |
| 46 | bool ready(); |
| 47 | bool canOpen(QString mime); |
| 48 | void open(QUrl url); |
| 49 | void play(); |
| 50 | void stop(); |
| 51 | void pause(); |
| 52 | bool close(); |
| 53 | void setPosition(QTime); |
| 54 | QTime position(); |
| 55 | double volume(); |
| 56 | void setVolume(double); |
| 57 | void disable(); |
| 58 | void enable(); |
| 59 | bool isDisabled(); |
| 60 | |
| 61 | QTime length(); |
| 62 | bool isPlaying(); |
| 63 | bool mediaPlayable(); |
| 64 | QStringList outputDevices(); |
| 65 | QString outputDeviceName(); |
| 66 | QString outputDeviceID(); |
| 67 | void setOutputDevice(QString deviceName); |
| 68 | void readDevices(); |
| 69 | QString defaultDeviceID(); |
| 70 | |
| 71 | double levelLeft(); |
| 72 | double levelRight(); |
| 73 | |
| 74 | void newpad (GstElement *decodebin, GstPad *pad, gpointer data); |
| 75 | static GstBusSyncReply bus_cb (GstBus *bus, GstMessage *msg, gpointer data); |
| 76 | Q_SIGNALS: |
| 77 | void finish(); |
| 78 | void error(); |
| 79 | void levelChanged(); |
| 80 | void positionChanged(); |
| 81 | void loadFinished(); |
| 82 | private slots: |
| 83 | void loadThreadFinished(); |
| 84 | void messageReceived(GstMessage* message); |
| 85 | |
| 86 | private: |
| 87 | struct MonitorPlayerPrivate *p; |
| 88 | |
| 89 | GstElement *pipeline; |
| 90 | GstBus *bus; |
| 91 | gint64 Gstart; |
| 92 | gint64 Glength; |
| 93 | void setLink(int, QUrl&); |
| 94 | void asyncOpen(QUrl url); |
| 95 | void cleanup(); |
| 96 | void sync_set_state(GstElement*, GstState); |
| 97 | |
| 98 | }; |
| 99 | |
| 100 | #endif // MONITORPLAYER_H |
| 101 | |
| 102 | |
| 103 | |
| 104 |