1
/* smplayer, GUI front-end for mplayer.
2
Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
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.
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.
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
23
#include <QProcess> // For QProcess::ProcessError
24
#include "mediadata.h"
25
#include "mediasettings.h"
37
class Core : public QObject
42
enum State { Stopped = 0, Playing = 1, Paused = 2 };
44
Core( MplayerWindow *mpw, QWidget* parent = 0 );
52
//! Return the current state
53
State state() { return _state; };
55
//! Return a string with the name of the current state,
56
//! so it can be printed on debugging messages.
57
QString stateToString();
60
//! Change the current state (Stopped, Playing or Paused)
61
//! And sends the stateChanged() signal.
62
void setState(State s);
65
//! Generic open, with autodetection of type
66
void open(QString file, int seek=-1);
67
void openFile(QString filename, int seek=-1);
68
void openStream(QString name);
70
void openDVD( bool from_folder, QString directory = "");
71
void openDVD(); // Plays title 1
72
void openDVD(int title = 1);
74
void openDVD(QString dvd_url);
75
void openVCD(int title = -1);
76
void openAudioCD(int title = -1);
78
void loadSub(const QString & sub);
81
void loadAudioFile(const QString & audiofile);
82
void unloadAudioFile();
87
void pause_and_frame_step();
92
//! Public restart, for the GUI.
95
//! Reopens the file (no restart)
98
void goToPos( int perc );
99
void goToSec( double sec );
102
void toggleRepeat(bool b);
105
void toggleFlip(bool b);
108
void toggleKaraoke();
109
void toggleKaraoke(bool b);
110
void toggleExtrastereo();
111
void toggleExtrastereo(bool b);
112
void toggleVolnorm();
113
void toggleVolnorm(bool b);
115
void setAudioChannels(int channels);
116
void setStereoMode(int mode);
119
void toggleAutophase();
120
void toggleAutophase(bool b);
121
void toggleDeblock();
122
void toggleDeblock(bool b);
124
void toggleDering(bool b);
126
void toggleNoise(bool b);
127
void togglePostprocessing();
128
void togglePostprocessing(bool b);
129
void changeDenoise(int);
131
void changeLetterbox(bool);
133
void changeUpscale(bool);
136
void sforward(); // + 10 seconds
137
void srewind(); // - 10 seconds
138
void forward(); // + 1 minute
139
void rewind(); // -1 minute
140
void fastforward(); // + 10 minutes
141
void fastrewind(); // - 10 minutes
142
void forward(int secs);
143
void rewind(int secs);
147
void setSpeed( double value );
154
void setVolume(int volume, bool force = false);
160
void setBrightness(int value);
161
void setContrast(int value);
162
void setGamma(int value);
163
void setHue(int value);
164
void setSaturation(int value);
166
void incBrightness();
167
void decBrightness();
174
void incSaturation();
175
void decSaturation();
180
void incAudioDelay();
181
void decAudioDelay();
186
void changeSubScale(double value);
190
//! Select next line in subtitle file
192
//! Select previous line in subtitle file
195
void changeDeinterlace(int);
196
void changeSubtitle(int);
198
void changeAudio(int);
200
void changeTitle(int);
201
void changeChapter(int);
204
void changeAngle(int);
205
void changeAspectRatio(int);
209
void changeSize(int); // Size of the window
210
void toggleDoubleSize();
211
void changePanscan(double); // Zoom on mplayerwindow
213
void changeRotate(int r);
219
void changeUseAss(bool);
220
void toggleClosedCaption(bool);
221
void toggleForcedSubsOnly(bool);
223
void visualizeMotionVectors(bool);
225
// Pass a command to mplayer by stdin:
226
void tellmp(const QString & command);
229
//! Returns the number of the first chapter in mkv
230
//! files. In some versions of mplayer is 0, in others 1
231
static int mkv_first_chapter();
232
static int dvd_first_chapter();
235
void changeCurrentSec(double sec);
237
void gotWindowResolution( int w, int h );
241
void gotStartingTime(double);
243
void finishRestart();
244
void processFinished();
245
void fileReachedEnd();
247
void updateLog(QString line);
249
void displayMessage(QString text);
250
void displayScreenshotName(QString filename);
252
void streamTitleAndUrlChanged(QString,QString);
253
void autosaveMplayerLog();
255
void watchState(Core::State state);
257
//! Called when a video has just started to play.
258
//! This function checks if the codec of video is ffh264 and if
259
//! the resolution is HD
260
void checkIfVideoIsHD();
263
void playNewFile(QString file, int seek=-1);
265
void initPlaying(int seek=-1);
266
void newMediaPlaying();
268
void startMplayer(QString file, double seek = -1 );
271
#ifndef NO_USE_INI_FILES
272
bool checkHaveSettingsSaved(QString filename);
273
void saveMediaInfo();
274
void loadMediaInfo(QString filename);
277
void initializeMenus();
278
void updateWidgets();
281
//! Returns true if changing the subscale requires to restart mplayer
282
bool subscale_need_restart();
286
void aboutToStartPlaying(); // Signal emited just before to start mplayer
288
void mediaInfoChanged();
289
void stateChanged(Core::State state);
290
void mediaStartPlay();
291
void mediaFinished(); // Media has arrived to the end.
292
void mediaStoppedByUser();
293
void showMessage(QString text);
294
void menusNeedInitialize();
295
void widgetsNeedUpdate();
296
void equalizerNeedsUpdate();
297
void showTime(double sec);
298
void posChanged(int); // To connect a slider
299
void showFrame(int frame);
300
void needResize(int w, int h);
302
void volumeChanged(int);
304
//! MPlayer started but finished with exit code != 0
305
void mplayerFinishedWithError(int exitCode);
307
//! MPlayer didn't started or crashed
308
void mplayerFailed(QProcess::ProcessError error);
310
// Resend signal from mplayerprocess:
311
void failedToParseMplayerVersion(QString line_with_mplayer_version);
314
MplayerProcess * proc;
315
MplayerWindow * mplayerwindow;
317
#ifndef NO_USE_INI_FILES
318
QSettings * file_settings;
322
WinScreenSaver * win_screensaver;
326
// Some variables to proper restart
327
bool we_are_restarting;
329
bool just_loaded_external_subs;
330
bool just_unloaded_external_subs;
332
bool change_volume_after_unpause;