| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2016 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 PLAYERPROCESS_H
|
|---|
| 20 | #define PLAYERPROCESS_H
|
|---|
| 21 |
|
|---|
| 22 | #include "myprocess.h"
|
|---|
| 23 | #include "mediadata.h"
|
|---|
| 24 | #include "playerid.h"
|
|---|
| 25 | #include "config.h"
|
|---|
| 26 | #include "assstyles.h"
|
|---|
| 27 | #include <QVariant>
|
|---|
| 28 | #ifdef Q_OS_OS2
|
|---|
| 29 | #include <QThread>
|
|---|
| 30 | #include <qt_os2.h>
|
|---|
| 31 | #endif
|
|---|
| 32 |
|
|---|
| 33 | #ifdef Q_OS_OS2
|
|---|
| 34 | class PipeThread : public QThread
|
|---|
| 35 | {
|
|---|
| 36 | public:
|
|---|
| 37 | PipeThread(const QByteArray t, const HPIPE pipe);
|
|---|
| 38 | ~PipeThread();
|
|---|
| 39 | void run();
|
|---|
| 40 |
|
|---|
| 41 | private:
|
|---|
| 42 | HPIPE hpipe;
|
|---|
| 43 | QByteArray text;
|
|---|
| 44 | };
|
|---|
| 45 | #endif
|
|---|
| 46 |
|
|---|
| 47 | class PlayerProcess : public MyProcess
|
|---|
| 48 | {
|
|---|
| 49 | Q_OBJECT
|
|---|
| 50 |
|
|---|
| 51 | public:
|
|---|
| 52 | enum ScreenshotType { Single = 0, Multiple = 1 };
|
|---|
| 53 |
|
|---|
| 54 | PlayerProcess(QObject * parent = 0);
|
|---|
| 55 |
|
|---|
| 56 | PlayerID::Player player() { return player_id; }
|
|---|
| 57 | bool isMPlayer() { return (player_id == PlayerID::MPLAYER); }
|
|---|
| 58 | bool isMPV() { return (player_id == PlayerID::MPV); }
|
|---|
| 59 |
|
|---|
| 60 | virtual bool start() = 0;
|
|---|
| 61 |
|
|---|
| 62 | void writeToStdin(QString text);
|
|---|
| 63 | MediaData mediaData() { return md; };
|
|---|
| 64 |
|
|---|
| 65 | // Command line options
|
|---|
| 66 | virtual void setMedia(const QString & media, bool is_playlist = false) = 0;
|
|---|
| 67 | virtual void setFixedOptions() = 0;
|
|---|
| 68 | virtual void disableInput() = 0;
|
|---|
| 69 | virtual void setOption(const QString & option_name, const QVariant & value = QVariant()) = 0;
|
|---|
| 70 | virtual void addUserOption(const QString & option) = 0;
|
|---|
| 71 | virtual void addVF(const QString & filter_name, const QVariant & value = QVariant()) = 0;
|
|---|
| 72 | virtual void addAF(const QString & filter_name, const QVariant & value = QVariant()) = 0;
|
|---|
| 73 | virtual void addStereo3DFilter(const QString & in, const QString & out) = 0;
|
|---|
| 74 | virtual void setSubStyles(const AssStyles & styles, const QString & assStylesFile = QString::null) = 0;
|
|---|
| 75 |
|
|---|
| 76 | // Slave commands
|
|---|
| 77 | virtual void quit() = 0;
|
|---|
| 78 | virtual void setVolume(int v) = 0;
|
|---|
| 79 | virtual void setOSD(int o) = 0;
|
|---|
| 80 | virtual void setAudio(int ID) = 0;
|
|---|
| 81 | virtual void setVideo(int ID) = 0;
|
|---|
| 82 | virtual void setSubtitle(int type, int ID) = 0;
|
|---|
| 83 | virtual void disableSubtitles() = 0;
|
|---|
| 84 | virtual void setSecondarySubtitle(int ID) = 0;
|
|---|
| 85 | virtual void disableSecondarySubtitles() = 0;
|
|---|
| 86 | virtual void setSubtitlesVisibility(bool b) = 0;
|
|---|
| 87 | virtual void seek(double secs, int mode, bool precise) = 0;
|
|---|
| 88 | virtual void mute(bool b) = 0;
|
|---|
| 89 | virtual void setPause(bool b) = 0;
|
|---|
| 90 | virtual void frameStep() = 0;
|
|---|
| 91 | virtual void frameBackStep() = 0;
|
|---|
| 92 | virtual void showOSDText(const QString & text, int duration, int level) = 0;
|
|---|
| 93 | virtual void showFilenameOnOSD() = 0;
|
|---|
| 94 | virtual void showTimeOnOSD() = 0;
|
|---|
| 95 | virtual void setContrast(int value) = 0;
|
|---|
| 96 | virtual void setBrightness(int value) = 0;
|
|---|
| 97 | virtual void setHue(int value) = 0;
|
|---|
| 98 | virtual void setSaturation(int value) = 0;
|
|---|
| 99 | virtual void setGamma(int value) = 0;
|
|---|
| 100 | virtual void setChapter(int ID) = 0;
|
|---|
| 101 | virtual void nextChapter() = 0;
|
|---|
| 102 | virtual void previousChapter() = 0;
|
|---|
| 103 | virtual void setExternalSubtitleFile(const QString & filename) = 0;
|
|---|
| 104 | virtual void setSubPos(int pos) = 0;
|
|---|
| 105 | virtual void setSubScale(double value) = 0;
|
|---|
| 106 | virtual void setSubStep(int value) = 0;
|
|---|
| 107 | #ifdef MPV_SUPPORT
|
|---|
| 108 | virtual void seekSub(int value) = 0;
|
|---|
| 109 | #endif
|
|---|
| 110 | virtual void setSubForcedOnly(bool b) = 0;
|
|---|
| 111 | virtual void setSpeed(double value) = 0;
|
|---|
| 112 | #ifdef MPLAYER_SUPPORT
|
|---|
| 113 | virtual void enableKaraoke(bool b) = 0;
|
|---|
| 114 | #endif
|
|---|
| 115 | virtual void enableExtrastereo(bool b) = 0;
|
|---|
| 116 | virtual void enableVolnorm(bool b, const QString & option) = 0;
|
|---|
| 117 | virtual void setAudioEqualizer(const QString & values) = 0;
|
|---|
| 118 | virtual void setAudioDelay(double delay) = 0;
|
|---|
| 119 | virtual void setSubDelay(double delay) = 0;
|
|---|
| 120 | virtual void setLoop(int v) = 0;
|
|---|
| 121 | virtual void takeScreenshot(ScreenshotType t, bool include_subtitles = false) = 0;
|
|---|
| 122 | #ifdef CAPTURE_STREAM
|
|---|
| 123 | virtual void switchCapturing() = 0;
|
|---|
| 124 | #endif
|
|---|
| 125 | virtual void setTitle(int ID) = 0;
|
|---|
| 126 | virtual void changeVF(const QString & filter, bool enable, const QVariant & option = QVariant()) = 0;
|
|---|
| 127 | virtual void changeStereo3DFilter(bool enable, const QString & in, const QString & out) = 0;
|
|---|
| 128 | #if DVDNAV_SUPPORT
|
|---|
| 129 | virtual void discSetMousePos(int x, int y) = 0;
|
|---|
| 130 | virtual void discButtonPressed(const QString & button_name) = 0;
|
|---|
| 131 | #endif
|
|---|
| 132 | virtual void setAspect(double aspect) = 0;
|
|---|
| 133 | virtual void setFullscreen(bool b) = 0;
|
|---|
| 134 | #if PROGRAM_SWITCH
|
|---|
| 135 | virtual void setTSProgram(int ID) = 0;
|
|---|
| 136 | #endif
|
|---|
| 137 | virtual void toggleDeinterlace() = 0;
|
|---|
| 138 | virtual void askForLength() = 0;
|
|---|
| 139 | virtual void setOSDScale(double value) = 0;
|
|---|
| 140 | virtual void setChannelsFile(const QString &) = 0;
|
|---|
| 141 |
|
|---|
| 142 | virtual void enableScreenshots(const QString & dir, const QString & templ = QString::null, const QString & format = QString::null) = 0;
|
|---|
| 143 |
|
|---|
| 144 | void setPausingPrefix(const QString & prefix) { pausing_prefix = prefix; };
|
|---|
| 145 |
|
|---|
| 146 | #ifdef CAPTURE_STREAM
|
|---|
| 147 | virtual void setCaptureDirectory(const QString & dir);
|
|---|
| 148 | #endif
|
|---|
| 149 |
|
|---|
| 150 | static PlayerProcess * createPlayerProcess(const QString & player_bin, QObject * parent = 0);
|
|---|
| 151 |
|
|---|
| 152 | #if defined(Q_OS_OS2)
|
|---|
| 153 | void PpipeOpen(const char *szPipeName);
|
|---|
| 154 | void PpipeClose();
|
|---|
| 155 | void PpipeWrite(const QByteArray text);
|
|---|
| 156 | #endif
|
|---|
| 157 |
|
|---|
| 158 | // Signals
|
|---|
| 159 | signals:
|
|---|
| 160 | void processExited();
|
|---|
| 161 | void lineAvailable(QString line);
|
|---|
| 162 |
|
|---|
| 163 | void receivedCurrentSec(double sec);
|
|---|
| 164 | void receivedCurrentFrame(int frame);
|
|---|
| 165 | void receivedPause();
|
|---|
| 166 | void receivedWindowResolution(int,int);
|
|---|
| 167 | void receivedNoVideo();
|
|---|
| 168 | void receivedVO(QString);
|
|---|
| 169 | void receivedAO(QString);
|
|---|
| 170 | void receivedEndOfFile();
|
|---|
| 171 | void mplayerFullyLoaded();
|
|---|
| 172 | void receivedStartingTime(double sec);
|
|---|
| 173 |
|
|---|
| 174 | void receivedCacheMessage(QString);
|
|---|
| 175 | void receivedCacheEmptyMessage(QString);
|
|---|
| 176 | void receivedCreatingIndex(QString);
|
|---|
| 177 | void receivedConnectingToMessage(QString);
|
|---|
| 178 | void receivedResolvingMessage(QString);
|
|---|
| 179 | void receivedBuffering();
|
|---|
| 180 | void receivedPlaying();
|
|---|
| 181 | void receivedScreenshot(QString);
|
|---|
| 182 | void receivedUpdatingFontCache();
|
|---|
| 183 | void receivedScanningFont(QString);
|
|---|
| 184 | void receivedForbiddenText();
|
|---|
| 185 |
|
|---|
| 186 | void receivedStreamTitle(QString);
|
|---|
| 187 | void receivedStreamTitleAndUrl(QString,QString);
|
|---|
| 188 |
|
|---|
| 189 | void failedToParseMplayerVersion(QString line_with_mplayer_version);
|
|---|
| 190 |
|
|---|
| 191 | #if NOTIFY_SUB_CHANGES
|
|---|
| 192 | //! Emitted if a new subtitle has been added or an old one changed
|
|---|
| 193 | void subtitleInfoChanged(const SubTracks &);
|
|---|
| 194 |
|
|---|
| 195 | //! Emitted when subtitle info has been received but there wasn't anything new
|
|---|
| 196 | void subtitleInfoReceivedAgain(const SubTracks &);
|
|---|
| 197 | #endif
|
|---|
| 198 | #if NOTIFY_AUDIO_CHANGES
|
|---|
| 199 | //! Emitted if a new audio track been added or an old one changed
|
|---|
| 200 | void audioInfoChanged(const Tracks &);
|
|---|
| 201 | #endif
|
|---|
| 202 | #if NOTIFY_VIDEO_CHANGES
|
|---|
| 203 | //! Emitted if a new video track been added or an old one changed
|
|---|
| 204 | void videoInfoChanged(const Tracks &);
|
|---|
| 205 | #endif
|
|---|
| 206 | #if NOTIFY_CHAPTER_CHANGES
|
|---|
| 207 | void chaptersChanged(const Chapters &);
|
|---|
| 208 | #endif
|
|---|
| 209 |
|
|---|
| 210 | #if DVDNAV_SUPPORT
|
|---|
| 211 | void receivedDVDTitle(int);
|
|---|
| 212 | void receivedDuration(double);
|
|---|
| 213 | void receivedTitleIsMenu();
|
|---|
| 214 | void receivedTitleIsMovie();
|
|---|
| 215 | #endif
|
|---|
| 216 |
|
|---|
| 217 | void receivedVideoBitrate(int);
|
|---|
| 218 | void receivedAudioBitrate(int);
|
|---|
| 219 |
|
|---|
| 220 | protected:
|
|---|
| 221 | MediaData md;
|
|---|
| 222 | QString pausing_prefix;
|
|---|
| 223 |
|
|---|
| 224 | #ifdef CAPTURE_STREAM
|
|---|
| 225 | QString capture_filename;
|
|---|
| 226 | #endif
|
|---|
| 227 |
|
|---|
| 228 | PlayerID::Player player_id;
|
|---|
| 229 |
|
|---|
| 230 | #if defined(Q_OS_OS2)
|
|---|
| 231 | PipeThread *pipeThread;
|
|---|
| 232 | HPIPE hpipe;
|
|---|
| 233 | PID pidMP;
|
|---|
| 234 | #endif
|
|---|
| 235 |
|
|---|
| 236 | };
|
|---|
| 237 |
|
|---|
| 238 | #endif
|
|---|