[186] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
| 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
| 3 |
|
---|
| 4 | This program is free software; you can redistribute it and/or modify
|
---|
| 5 | it under the terms of the GNU General Public License as published by
|
---|
| 6 | the Free Software Foundation; either version 2 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 General Public License
|
---|
| 15 | along with this program; if not, write to the Free Software
|
---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 17 | */
|
---|
| 18 |
|
---|
| 19 | #ifndef CHROMECAST_H
|
---|
| 20 | #define CHROMECAST_H
|
---|
| 21 |
|
---|
| 22 | #include <QString>
|
---|
| 23 | #include <QStringList>
|
---|
| 24 | #include <QProcess>
|
---|
| 25 |
|
---|
| 26 | class QSettings;
|
---|
| 27 |
|
---|
| 28 | class Chromecast : public QObject {
|
---|
| 29 | Q_OBJECT
|
---|
| 30 |
|
---|
| 31 | public:
|
---|
| 32 | Chromecast(QObject * parent = 0);
|
---|
| 33 | ~Chromecast();
|
---|
| 34 |
|
---|
| 35 | void openStream(const QString & url, const QString & title);
|
---|
| 36 | void openLocal(const QString & file, const QString & title);
|
---|
| 37 |
|
---|
| 38 | static Chromecast * instance();
|
---|
| 39 | static void deleteInstance();
|
---|
| 40 |
|
---|
| 41 | static QStringList localAddresses();
|
---|
| 42 | static QString findLocalAddress();
|
---|
| 43 |
|
---|
| 44 | // Server settings
|
---|
| 45 | void setServerPort(int port) {
|
---|
| 46 | if (port != server_port) server_needs_restart = true;
|
---|
| 47 | server_port = port;
|
---|
| 48 | }
|
---|
| 49 | int serverPort() { return server_port; };
|
---|
| 50 |
|
---|
| 51 | void setLocalAddress(const QString & address) {
|
---|
| 52 | if (address != local_address) server_needs_restart = true;
|
---|
| 53 | local_address = address;
|
---|
| 54 | };
|
---|
| 55 | QString localAddress() { return local_address; };
|
---|
| 56 |
|
---|
| 57 | void setDirectoryListing(bool enabled) {
|
---|
| 58 | if (enabled != directory_listing) server_needs_restart = true;
|
---|
| 59 | directory_listing = enabled;
|
---|
| 60 | };
|
---|
| 61 | bool directoryListing() { return directory_listing; };
|
---|
| 62 |
|
---|
| 63 | void setSettings(QSettings * set) { settings = set; loadSettings(); };
|
---|
| 64 |
|
---|
| 65 | protected:
|
---|
| 66 | void startServer(QString doc_root);
|
---|
| 67 | void stopServer();
|
---|
| 68 |
|
---|
| 69 | void loadSettings();
|
---|
| 70 | void saveSettings();
|
---|
| 71 |
|
---|
| 72 | protected slots:
|
---|
| 73 | void readProcessOutput();
|
---|
| 74 | void processFinished(int exit_code, QProcess::ExitStatus exit_status);
|
---|
| 75 | void processError(QProcess::ProcessError error);
|
---|
| 76 |
|
---|
| 77 | protected:
|
---|
| 78 | QProcess * server_process;
|
---|
| 79 | QSettings * settings;
|
---|
| 80 |
|
---|
| 81 | int server_port;
|
---|
| 82 | QString local_address;
|
---|
| 83 | bool directory_listing;
|
---|
| 84 |
|
---|
| 85 | bool server_needs_restart;
|
---|
| 86 |
|
---|
| 87 | private:
|
---|
| 88 | static Chromecast * instance_obj;
|
---|
| 89 | };
|
---|
| 90 |
|
---|
| 91 | #endif
|
---|