1
/* smplayer, GUI front-end for mplayer.
2
Copyright (C) 2006-2009 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"
26
#include "mplayerprocess.h"
29
#define NEW_SETTINGS_MANAGEMENT 1
31
#ifndef NO_USE_INI_FILES
32
#if NEW_SETTINGS_MANAGEMENT
33
class FileSettingsBase;
42
#ifdef SCREENSAVER_OFF
47
class Core : public QObject
52
enum State { Stopped = 0, Playing = 1, Paused = 2 };
54
Core( MplayerWindow *mpw, QWidget* parent = 0 );
60
//! Return the current state
61
State state() { return _state; };
63
//! Return a string with the name of the current state,
64
//! so it can be printed on debugging messages.
65
QString stateToString();
68
//! Change the current state (Stopped, Playing or Paused)
69
//! And sends the stateChanged() signal.
70
void setState(State s);
73
//! Generic open, with autodetection of type
74
void open(QString file, int seek=-1);
75
void openFile(QString filename, int seek=-1);
76
void openStream(QString name);
78
void openDVD( bool from_folder, QString directory = "");
79
void openDVD(); // Plays title 1
80
void openDVD(int title = 1);
82
void openDVD(QString dvd_url);
83
void openVCD(int title = -1);
84
void openAudioCD(int title = -1);
86
void loadSub(const QString & sub);
89
//! Forces to use the specified subtitle file. It's not loaded immediately but stored
90
//! and will be used for the next video. After that the variable is cleared.
91
void setInitialSubtitle(const QString & subtitle_file) { initial_subtitle = subtitle_file; };
93
void loadAudioFile(const QString & audiofile);
94
void unloadAudioFile();
99
void pause_and_frame_step();
104
//! Public restart, for the GUI.
107
//! Reopens the file (no restart)
110
#ifdef SEEKBAR_RESOLUTION
111
void goToPosition( int value );
113
void goToPos( int perc );
115
void goToSec( double sec );
118
void toggleRepeat(bool b);
121
void toggleFlip(bool b);
124
void toggleMirror(bool b);
127
void toggleKaraoke();
128
void toggleKaraoke(bool b);
129
void toggleExtrastereo();
130
void toggleExtrastereo(bool b);
131
void toggleVolnorm();
132
void toggleVolnorm(bool b);
134
void setAudioChannels(int channels);
135
void setStereoMode(int mode);
138
void toggleAutophase();
139
void toggleAutophase(bool b);
140
void toggleDeblock();
141
void toggleDeblock(bool b);
143
void toggleDering(bool b);
145
void toggleNoise(bool b);
146
void togglePostprocessing();
147
void togglePostprocessing(bool b);
148
void changeDenoise(int);
150
void changeLetterbox(bool);
152
void changeUpscale(bool);
155
void sforward(); // + 10 seconds
156
void srewind(); // - 10 seconds
157
void forward(); // + 1 minute
158
void rewind(); // -1 minute
159
void fastforward(); // + 10 minutes
160
void fastrewind(); // - 10 minutes
161
void forward(int secs);
162
void rewind(int secs);
166
void setSpeed( double value );
167
void incSpeed10(); //!< Inc speed 10%
168
void decSpeed10(); //!< Dec speed 10%
169
void incSpeed4(); //!< Inc speed 4%
170
void decSpeed4(); //!< Dec speed 4%
171
void incSpeed1(); //!< Inc speed 1%
172
void decSpeed1(); //!< Dec speed 1%
177
void setVolume(int volume, bool force = false);
183
void setBrightness(int value);
184
void setContrast(int value);
185
void setGamma(int value);
186
void setHue(int value);
187
void setSaturation(int value);
189
void incBrightness();
190
void decBrightness();
197
void incSaturation();
198
void decSaturation();
200
void setSubDelay(int delay);
204
void setAudioDelay(int delay);
205
void incAudioDelay();
206
void decAudioDelay();
211
void changeSubScale(double value);
215
//! Select next line in subtitle file
217
//! Select previous line in subtitle file
221
void setAudioEqualizer(AudioEqualizerList values, bool restart = false);
222
void setAudioAudioEqualizerRestart(AudioEqualizerList values) { setAudioEqualizer(values, true); };
223
void updateAudioEqualizer();
225
void setAudioEq0(int value);
226
void setAudioEq1(int value);
227
void setAudioEq2(int value);
228
void setAudioEq3(int value);
229
void setAudioEq4(int value);
230
void setAudioEq5(int value);
231
void setAudioEq6(int value);
232
void setAudioEq7(int value);
233
void setAudioEq8(int value);
234
void setAudioEq9(int value);
236
void changeDeinterlace(int);
237
void changeSubtitle(int);
239
void changeAudio(int ID, bool allow_restart = true);
241
void changeVideo(int ID, bool allow_restart = true);
243
void changeTitle(int);
244
void changeChapter(int);
247
void changeAngle(int);
248
void changeAspectRatio(int);
250
void nextAspectRatio();
255
void changeSize(int); // Size of the window
256
void toggleDoubleSize();
257
void changePanscan(double); // Zoom on mplayerwindow
259
void changeRotate(int r);
262
void changeAdapter(int n);
269
void autoPanscanFromLetterbox(double video_aspect);
270
void autoPanscanFor169();
271
void autoPanscanFor235();
273
void changeUseAss(bool);
274
void toggleClosedCaption(bool);
275
void toggleForcedSubsOnly(bool);
277
void visualizeMotionVectors(bool);
291
// Pass a command to mplayer by stdin:
292
void tellmp(const QString & command);
295
//! Returns the number of the first chapter in
296
//! files. In some versions of mplayer is 0, in others 1
297
static int firstChapter();
298
#if !GENERIC_CHAPTER_SUPPORT
299
static int dvdFirstChapter();
302
#ifndef NO_USE_INI_FILES
303
void changeFileSettingsMethod(QString method);
307
//! Returns the prefix to keep pausing on slave commands
308
QString pausing_prefix();
311
void changeCurrentSec(double sec);
313
void gotWindowResolution( int w, int h );
317
void gotStartingTime(double);
319
void finishRestart();
320
void processFinished();
321
void fileReachedEnd();
323
void displayMessage(QString text);
324
void displayScreenshotName(QString filename);
325
void displayUpdatingFontCache();
327
void streamTitleAndUrlChanged(QString,QString);
329
void watchState(Core::State state);
331
//! Called when a video has just started to play.
332
//! This function checks if the codec of video is ffh264 and if
333
//! the resolution is HD
334
void checkIfVideoIsHD();
336
#if DELAYED_AUDIO_SETUP_ON_STARTUP
337
void initAudioTrack();
339
#if NOTIFY_AUDIO_CHANGES
340
void initAudioTrack(const Tracks &);
342
#if NOTIFY_SUB_CHANGES
343
void initSubtitleTrack(const SubTracks &);
344
void setSubtitleTrackAgain(const SubTracks &);
347
void dvdTitleChanged(int);
348
void durationChanged(double);
350
void dvdnavUpdateMousePos(QPoint);
354
void playNewFile(QString file, int seek=-1);
356
void initPlaying(int seek=-1);
357
void newMediaPlaying();
359
void startMplayer(QString file, double seek = -1 );
362
#ifndef NO_USE_INI_FILES
363
#if !NEW_SETTINGS_MANAGEMENT
364
bool checkHaveSettingsSaved(QString filename);
365
void loadMediaInfo(QString filename);
367
void saveMediaInfo();
370
void initializeMenus();
371
void updateWidgets();
373
//! Returns true if changing the subscale requires to restart mplayer
374
bool subscale_need_restart();
377
void aboutToStartPlaying(); // Signal emited just before to start mplayer
379
void mediaInfoChanged();
380
void stateChanged(Core::State state);
381
void mediaStartPlay();
382
void mediaFinished(); // Media has arrived to the end.
383
void mediaStoppedByUser();
384
void showMessage(QString text);
385
void menusNeedInitialize();
386
void widgetsNeedUpdate();
387
void videoEqualizerNeedsUpdate();
388
void audioEqualizerNeedsUpdate();
389
void showTime(double sec);
390
#ifdef SEEKBAR_RESOLUTION
391
void positionChanged(int); // To connect a slider
393
void posChanged(int); // To connect a slider
395
void showFrame(int frame);
396
void needResize(int w, int h);
398
void volumeChanged(int);
399
#if NOTIFY_AUDIO_CHANGES
400
void audioTracksChanged();
403
//! MPlayer started but finished with exit code != 0
404
void mplayerFinishedWithError(int exitCode);
406
//! MPlayer didn't started or crashed
407
void mplayerFailed(QProcess::ProcessError error);
409
// Resend signal from mplayerprocess:
410
void failedToParseMplayerVersion(QString line_with_mplayer_version);
412
//! A new line from the mplayer output is available
413
void logLineAvailable(QString);
416
MplayerProcess * proc;
417
MplayerWindow * mplayerwindow;
419
#ifndef NO_USE_INI_FILES
420
#if NEW_SETTINGS_MANAGEMENT
421
FileSettingsBase * file_settings;
423
QSettings * file_settings;
428
#ifdef SCREENSAVER_OFF
429
WinScreenSaver * win_screensaver;
434
// Some variables to proper restart
435
bool we_are_restarting;
437
bool just_loaded_external_subs;
438
bool just_unloaded_external_subs;
440
bool change_volume_after_unpause;
442
QString initial_subtitle;