| 1 | /* |
| 2 | Copyright (C) 2011-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 | #ifndef PLAYER_H |
| 18 | #define PLAYER_H |
| 19 | |
| 20 | #include <QWidget> |
| 21 | #include <QtCore> |
| 22 | |
| 23 | #define GST_DISABLE_LOADSAVE 1 |
| 24 | #define GST_DISABLE_REGISTRY 1 |
| 25 | #define GST_DISABLE_DEPRECATED 1 |
| 26 | |
| 27 | #include <gst/gst.h> |
| 28 | |
| 29 | class Player : public QWidget { |
| 30 | Q_OBJECT |
| 31 | public: |
| 32 | Player(QWidget* parent = nullptr); |
| 33 | ~Player(); |
| 34 | |
| 35 | bool prepare(); |
| 36 | bool ready(); |
| 37 | bool canOpen(QString mime); |
| 38 | void open(QUrl url); |
| 39 | void play(); |
| 40 | void stop(); |
| 41 | void pause(); |
| 42 | bool close(); |
| 43 | void setPosition(QTime); |
| 44 | QTime position(); |
| 45 | double volume(); |
| 46 | void setVolume(double); |
| 47 | void setGain(double); |
| 48 | void setEqualizer(QString, double); |
| 49 | |
| 50 | QTime length(); |
| 51 | bool isPlaying(); |
| 52 | bool mediaPlayable(); |
| 53 | QString lastError; |
| 54 | |
| 55 | double levelLeft(); |
| 56 | double levelRight(); |
| 57 | double levelOutLeft(); |
| 58 | double levelOutRight(); |
| 59 | |
| 60 | void newpad(GstElement* decodebin, GstPad* pad, gpointer data); |
| 61 | static GstBusSyncReply bus_cb(GstBus* bus, GstMessage* msg, gpointer data); |
| 62 | Q_SIGNALS: |
| 63 | void finish(); |
| 64 | void error(); |
| 65 | void levelChanged(); |
| 66 | void positionChanged(); |
| 67 | void loadFinished(); |
| 68 | |
| 69 | private slots: |
| 70 | void loadThreadFinished(); |
| 71 | void messageReceived(GstMessage* message); |
| 72 | |
| 73 | private: |
| 74 | struct PlayerPrivate* p; |
| 75 | |
| 76 | GstElement* pipeline; |
| 77 | GstBus* bus; |
| 78 | gint64 Gstart, Glength; |
| 79 | void setLink(int, QUrl&); |
| 80 | void asyncOpen(QUrl url); |
| 81 | void cleanup(); |
| 82 | void sync_set_state(GstElement*, GstState); |
| 83 | }; |
| 84 | |
| 85 | #endif |