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 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 setAMarker(int sec) = 0;
|
---|
122 | virtual void setBMarker(int sec) = 0;
|
---|
123 | virtual void clearABMarkers() = 0;
|
---|
124 | virtual void takeScreenshot(ScreenshotType t, bool include_subtitles = false) = 0;
|
---|
125 | #ifdef CAPTURE_STREAM
|
---|
126 | virtual void switchCapturing() = 0;
|
---|
127 | #endif
|
---|
128 | virtual void setTitle(int ID) = 0;
|
---|
129 | virtual void changeVF(const QString & filter, bool enable, const QVariant & option = QVariant()) = 0;
|
---|
130 | virtual void changeStereo3DFilter(bool enable, const QString & in, const QString & out) = 0;
|
---|
131 | #if DVDNAV_SUPPORT
|
---|
132 | virtual void discSetMousePos(int x, int y) = 0;
|
---|
133 | virtual void discButtonPressed(const QString & button_name) = 0;
|
---|
134 | #endif
|
---|
135 | virtual void setAspect(double aspect) = 0;
|
---|
136 | virtual void setFullscreen(bool b) = 0;
|
---|
137 | #if PROGRAM_SWITCH
|
---|
138 | virtual void setTSProgram(int ID) = 0;
|
---|
139 | #endif
|
---|
140 | virtual void toggleDeinterlace() = 0;
|
---|
141 | virtual void askForLength() = 0;
|
---|
142 | virtual void setOSDScale(double value) = 0;
|
---|
143 | virtual void setChannelsFile(const QString &) = 0;
|
---|
144 |
|
---|
145 | virtual void enableScreenshots(const QString & dir, const QString & templ = QString::null, const QString & format = QString::null) = 0;
|
---|
146 |
|
---|
147 | void setPausingPrefix(const QString & prefix) { pausing_prefix = prefix; };
|
---|
148 |
|
---|
149 | void setOSDMediaInfo(const QString & s) { osd_media_info = s; };
|
---|
150 | QString OSDMediaInfo() { return osd_media_info; };
|
---|
151 |
|
---|
152 | #ifdef CAPTURE_STREAM
|
---|
153 | virtual void setCaptureDirectory(const QString & dir);
|
---|
154 | #endif
|
---|
155 |
|
---|
156 | static PlayerProcess * createPlayerProcess(const QString & player_bin, QObject * parent = 0);
|
---|
157 |
|
---|
158 | #if defined(Q_OS_OS2)
|
---|
159 | void PpipeOpen(const char *szPipeName);
|
---|
160 | void PpipeClose();
|
---|
161 | void PpipeWrite(const QByteArray text);
|
---|
162 | #endif
|
---|
163 |
|
---|
164 | // Signals
|
---|
165 | signals:
|
---|
166 | void processExited();
|
---|
167 | void lineAvailable(QString line);
|
---|
168 |
|
---|
169 | void receivedCurrentSec(double sec);
|
---|
170 | void receivedCurrentFrame(int frame);
|
---|
171 | void receivedPause();
|
---|
172 | void receivedWindowResolution(int,int);
|
---|
173 | void receivedNoVideo();
|
---|
174 | void receivedVO(QString);
|
---|
175 | void receivedAO(QString);
|
---|
176 | void receivedEndOfFile();
|
---|
177 | void mplayerFullyLoaded();
|
---|
178 | void receivedStartingTime(double sec);
|
---|
179 |
|
---|
180 | void receivedCacheMessage(QString);
|
---|
181 | void receivedCacheEmptyMessage(QString);
|
---|
182 | void receivedCreatingIndex(QString);
|
---|
183 | void receivedConnectingToMessage(QString);
|
---|
184 | void receivedResolvingMessage(QString);
|
---|
185 | void receivedBuffering();
|
---|
186 | void receivedPlaying();
|
---|
187 | void receivedScreenshot(QString);
|
---|
188 | void receivedUpdatingFontCache();
|
---|
189 | void receivedScanningFont(QString);
|
---|
190 | void receivedForbiddenText();
|
---|
191 |
|
---|
192 | void receivedStreamTitle(QString);
|
---|
193 | void receivedStreamTitleAndUrl(QString,QString);
|
---|
194 |
|
---|
195 | void failedToParseMplayerVersion(QString line_with_mplayer_version);
|
---|
196 |
|
---|
197 | #if NOTIFY_SUB_CHANGES
|
---|
198 | //! Emitted if a new subtitle has been added or an old one changed
|
---|
199 | void subtitleInfoChanged(const SubTracks &);
|
---|
200 |
|
---|
201 | //! Emitted when subtitle info has been received but there wasn't anything new
|
---|
202 | void subtitleInfoReceivedAgain(const SubTracks &);
|
---|
203 | #endif
|
---|
204 | #if NOTIFY_AUDIO_CHANGES
|
---|
205 | //! Emitted if a new audio track been added or an old one changed
|
---|
206 | void audioInfoChanged(const Tracks &);
|
---|
207 | #endif
|
---|
208 | #if NOTIFY_VIDEO_CHANGES
|
---|
209 | //! Emitted if a new video track been added or an old one changed
|
---|
210 | void videoInfoChanged(const Tracks &);
|
---|
211 | #endif
|
---|
212 | #if NOTIFY_CHAPTER_CHANGES
|
---|
213 | void chaptersChanged(const Chapters &);
|
---|
214 | #endif
|
---|
215 |
|
---|
216 | #if DVDNAV_SUPPORT
|
---|
217 | void receivedDVDTitle(int);
|
---|
218 | void receivedDuration(double);
|
---|
219 | void receivedTitleIsMenu();
|
---|
220 | void receivedTitleIsMovie();
|
---|
221 | #endif
|
---|
222 |
|
---|
223 | void receivedVideoBitrate(int);
|
---|
224 | void receivedAudioBitrate(int);
|
---|
225 |
|
---|
226 | protected:
|
---|
227 | MediaData md;
|
---|
228 | QString pausing_prefix;
|
---|
229 |
|
---|
230 | #ifdef CAPTURE_STREAM
|
---|
231 | QString capture_filename;
|
---|
232 | #endif
|
---|
233 |
|
---|
234 | PlayerID::Player player_id;
|
---|
235 |
|
---|
236 | #if defined(Q_OS_OS2)
|
---|
237 | PipeThread *pipeThread;
|
---|
238 | HPIPE hpipe;
|
---|
239 | PID pidMP;
|
---|
240 | #endif
|
---|
241 | QString osd_media_info;
|
---|
242 | };
|
---|
243 |
|
---|
244 | #endif
|
---|