~ubuntu-branches/debian/sid/smplayer/sid

« back to all changes in this revision

Viewing changes to src/core.h

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-03-31 23:05:43 UTC
  • mto: (1.1.9 upstream) (3.1.2 squeeze)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090331230543-nsklbxenl2hf2n6h
Tags: upstream-0.6.7
ImportĀ upstreamĀ versionĀ 0.6.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  smplayer, GUI front-end for mplayer.
 
2
    Copyright (C) 2006-2009 Ricardo Villalba <rvm@escomposlinux.org>
 
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 _CORE_H_
 
20
#define _CORE_H_
 
21
 
 
22
#include <QObject>
 
23
#include <QProcess> // For QProcess::ProcessError
 
24
#include "mediadata.h"
 
25
#include "mediasettings.h"
 
26
#include "mplayerprocess.h"
 
27
#include "config.h"
 
28
 
 
29
#define NEW_SETTINGS_MANAGEMENT 1
 
30
 
 
31
#ifndef NO_USE_INI_FILES
 
32
#if NEW_SETTINGS_MANAGEMENT
 
33
class FileSettingsBase;
 
34
#endif
 
35
#endif
 
36
 
 
37
class MplayerProcess;
 
38
class MplayerWindow;
 
39
class QSettings;
 
40
 
 
41
#ifdef Q_OS_WIN
 
42
#ifdef SCREENSAVER_OFF
 
43
class WinScreenSaver;
 
44
#endif
 
45
#endif
 
46
 
 
47
class Core : public QObject
 
48
{
 
49
    Q_OBJECT
 
50
    
 
51
public:
 
52
        enum State { Stopped = 0, Playing = 1, Paused = 2 };
 
53
 
 
54
    Core( MplayerWindow *mpw, QWidget* parent = 0 );
 
55
    ~Core();
 
56
 
 
57
    MediaData mdat;
 
58
        MediaSettings mset;
 
59
 
 
60
        //! Return the current state
 
61
        State state() { return _state; };
 
62
 
 
63
        //! Return a string with the name of the current state,
 
64
        //! so it can be printed on debugging messages.
 
65
        QString stateToString();
 
66
 
 
67
protected:
 
68
        //! Change the current state (Stopped, Playing or Paused)
 
69
        //! And sends the stateChanged() signal.
 
70
        void setState(State s);
 
71
    
 
72
public slots:
 
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);
 
77
        /*
 
78
        void openDVD( bool from_folder, QString directory = "");
 
79
        void openDVD(); // Plays title 1
 
80
        void openDVD(int title = 1);
 
81
        */
 
82
        void openDVD(QString dvd_url);
 
83
        void openVCD(int title = -1);
 
84
        void openAudioCD(int title = -1);
 
85
 
 
86
        void loadSub(const QString & sub);
 
87
        void unloadSub();
 
88
 
 
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; };
 
92
 
 
93
        void loadAudioFile(const QString & audiofile);
 
94
        void unloadAudioFile();
 
95
 
 
96
    void stop(); 
 
97
    void play();
 
98
        void play_or_pause();
 
99
    void pause_and_frame_step();
 
100
        void pause();
 
101
        void frameStep();
 
102
        void screenshot();
 
103
 
 
104
        //! Public restart, for the GUI.
 
105
        void restart();
 
106
 
 
107
        //! Reopens the file (no restart)
 
108
        void reload();
 
109
 
 
110
#ifdef SEEKBAR_RESOLUTION
 
111
    void goToPosition( int value );
 
112
#else
 
113
    void goToPos( int perc );
 
114
#endif
 
115
    void goToSec( double sec );
 
116
 
 
117
        void toggleRepeat();
 
118
        void toggleRepeat(bool b);
 
119
 
 
120
        void toggleFlip();
 
121
        void toggleFlip(bool b);
 
122
 
 
123
        void toggleMirror();
 
124
        void toggleMirror(bool b);
 
125
 
 
126
        // Audio filters
 
127
        void toggleKaraoke();
 
128
        void toggleKaraoke(bool b);
 
129
        void toggleExtrastereo();
 
130
        void toggleExtrastereo(bool b);
 
131
        void toggleVolnorm();
 
132
        void toggleVolnorm(bool b);
 
133
 
 
134
        void setAudioChannels(int channels);
 
135
        void setStereoMode(int mode);
 
136
 
 
137
        // Video filters
 
138
        void toggleAutophase();
 
139
        void toggleAutophase(bool b);
 
140
        void toggleDeblock();
 
141
        void toggleDeblock(bool b);
 
142
        void toggleDering();
 
143
        void toggleDering(bool b);
 
144
        void toggleNoise();
 
145
        void toggleNoise(bool b);
 
146
        void togglePostprocessing();
 
147
        void togglePostprocessing(bool b);
 
148
        void changeDenoise(int);
 
149
#if NEW_ASPECT_CODE
 
150
        void changeLetterbox(bool);
 
151
#endif
 
152
        void changeUpscale(bool);
 
153
 
 
154
        void seek(int secs);
 
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);
 
163
        void wheelUp();
 
164
        void wheelDown();
 
165
 
 
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%
 
173
        void doubleSpeed();
 
174
        void halveSpeed();
 
175
        void normalSpeed();
 
176
 
 
177
    void setVolume(int volume, bool force = false);
 
178
        void switchMute();
 
179
        void mute(bool b);
 
180
        void incVolume();
 
181
        void decVolume();
 
182
 
 
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);
 
188
 
 
189
        void incBrightness();
 
190
        void decBrightness();
 
191
        void incContrast();
 
192
        void decContrast();
 
193
        void incGamma();
 
194
        void decGamma();
 
195
        void incHue();
 
196
        void decHue();
 
197
        void incSaturation();
 
198
        void decSaturation();
 
199
 
 
200
        void setSubDelay(int delay);
 
201
        void incSubDelay();
 
202
        void decSubDelay();
 
203
 
 
204
        void setAudioDelay(int delay);
 
205
        void incAudioDelay();
 
206
        void decAudioDelay();
 
207
 
 
208
        void incSubPos();
 
209
        void decSubPos();
 
210
 
 
211
        void changeSubScale(double value);
 
212
        void incSubScale();
 
213
        void decSubScale();
 
214
 
 
215
        //! Select next line in subtitle file
 
216
        void incSubStep();
 
217
        //! Select previous line in subtitle file
 
218
        void decSubStep();
 
219
 
 
220
        //! Audio equalizer
 
221
        void setAudioEqualizer(AudioEqualizerList values, bool restart = false);
 
222
        void setAudioAudioEqualizerRestart(AudioEqualizerList values) { setAudioEqualizer(values, true); };
 
223
        void updateAudioEqualizer();
 
224
 
 
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);
 
235
 
 
236
        void changeDeinterlace(int);
 
237
    void changeSubtitle(int);
 
238
        void nextSubtitle();
 
239
        void changeAudio(int ID, bool allow_restart = true);
 
240
        void nextAudio();
 
241
        void changeVideo(int ID, bool allow_restart = true);
 
242
        void nextVideo();
 
243
        void changeTitle(int);
 
244
        void changeChapter(int);
 
245
        void prevChapter();
 
246
        void nextChapter();
 
247
        void changeAngle(int);
 
248
        void changeAspectRatio(int);
 
249
#if NEW_ASPECT_CODE
 
250
        void nextAspectRatio();
 
251
#endif
 
252
        void changeOSD(int);
 
253
        void nextOSD();
 
254
 
 
255
        void changeSize(int); // Size of the window
 
256
        void toggleDoubleSize();
 
257
        void changePanscan(double); // Zoom on mplayerwindow
 
258
 
 
259
        void changeRotate(int r);
 
260
 
 
261
#if USE_ADAPTER
 
262
        void changeAdapter(int n);
 
263
#endif
 
264
 
 
265
        void incPanscan();
 
266
        void decPanscan();
 
267
        void resetPanscan();
 
268
        void autoPanscan();
 
269
        void autoPanscanFromLetterbox(double video_aspect);
 
270
        void autoPanscanFor169();
 
271
        void autoPanscanFor235();
 
272
 
 
273
        void changeUseAss(bool);
 
274
        void toggleClosedCaption(bool);
 
275
        void toggleForcedSubsOnly(bool);
 
276
 
 
277
        void visualizeMotionVectors(bool);
 
278
 
 
279
#if DVDNAV_SUPPORT
 
280
        // dvdnav buttons
 
281
        void dvdnavUp();
 
282
        void dvdnavDown();
 
283
        void dvdnavLeft();
 
284
        void dvdnavRight();
 
285
        void dvdnavMenu();
 
286
        void dvdnavSelect();
 
287
        void dvdnavPrev();
 
288
        void dvdnavMouse();
 
289
#endif
 
290
 
 
291
    // Pass a command to mplayer by stdin:
 
292
    void tellmp(const QString & command);
 
293
 
 
294
public:
 
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();
 
300
#endif
 
301
 
 
302
#ifndef NO_USE_INI_FILES
 
303
        void changeFileSettingsMethod(QString method);
 
304
#endif
 
305
 
 
306
protected:
 
307
        //! Returns the prefix to keep pausing on slave commands
 
308
        QString pausing_prefix();
 
309
 
 
310
protected slots:
 
311
    void changeCurrentSec(double sec);
 
312
    void changePause();
 
313
        void gotWindowResolution( int w, int h );
 
314
        void gotNoVideo();
 
315
        void gotVO(QString);
 
316
        void gotAO(QString);
 
317
        void gotStartingTime(double);
 
318
 
 
319
        void finishRestart();
 
320
    void processFinished();
 
321
        void fileReachedEnd();
 
322
    
 
323
        void displayMessage(QString text);
 
324
        void displayScreenshotName(QString filename);
 
325
        void displayUpdatingFontCache();
 
326
 
 
327
        void streamTitleAndUrlChanged(QString,QString);
 
328
        
 
329
        void watchState(Core::State state);
 
330
 
 
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();
 
335
 
 
336
#if DELAYED_AUDIO_SETUP_ON_STARTUP
 
337
        void initAudioTrack();
 
338
#endif
 
339
#if NOTIFY_AUDIO_CHANGES
 
340
        void initAudioTrack(const Tracks &);
 
341
#endif
 
342
#if NOTIFY_SUB_CHANGES
 
343
        void initSubtitleTrack(const SubTracks &);
 
344
        void setSubtitleTrackAgain(const SubTracks &);
 
345
#endif
 
346
#if DVDNAV_SUPPORT
 
347
        void dvdTitleChanged(int);
 
348
        void durationChanged(double);
 
349
        void askForInfo();
 
350
        void dvdnavUpdateMousePos(QPoint);
 
351
#endif
 
352
 
 
353
protected:
 
354
        void playNewFile(QString file, int seek=-1);
 
355
        void restartPlay();
 
356
        void initPlaying(int seek=-1);
 
357
        void newMediaPlaying();
 
358
 
 
359
    void startMplayer(QString file, double seek = -1 );
 
360
        void stopMplayer();
 
361
 
 
362
#ifndef NO_USE_INI_FILES
 
363
        #if !NEW_SETTINGS_MANAGEMENT
 
364
        bool checkHaveSettingsSaved(QString filename);
 
365
        void loadMediaInfo(QString filename);
 
366
        #endif
 
367
        void saveMediaInfo();
 
368
#endif
 
369
 
 
370
    void initializeMenus();
 
371
        void updateWidgets();
 
372
 
 
373
        //! Returns true if changing the subscale requires to restart mplayer
 
374
        bool subscale_need_restart();
 
375
 
 
376
signals:
 
377
        void aboutToStartPlaying(); // Signal emited just before to start mplayer
 
378
        void mediaLoaded();
 
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
 
392
#else
 
393
        void posChanged(int); // To connect a slider
 
394
#endif
 
395
        void showFrame(int frame);
 
396
        void needResize(int w, int h);
 
397
        void noVideo();
 
398
        void volumeChanged(int);
 
399
#if NOTIFY_AUDIO_CHANGES
 
400
        void audioTracksChanged();
 
401
#endif
 
402
 
 
403
        //! MPlayer started but finished with exit code != 0
 
404
        void mplayerFinishedWithError(int exitCode);
 
405
 
 
406
        //! MPlayer didn't started or crashed
 
407
        void mplayerFailed(QProcess::ProcessError error);
 
408
 
 
409
        // Resend signal from mplayerprocess:
 
410
        void failedToParseMplayerVersion(QString line_with_mplayer_version);
 
411
 
 
412
        //! A new line from the mplayer output is available
 
413
        void logLineAvailable(QString);
 
414
 
 
415
protected:
 
416
    MplayerProcess * proc;
 
417
    MplayerWindow * mplayerwindow;
 
418
 
 
419
#ifndef NO_USE_INI_FILES
 
420
        #if NEW_SETTINGS_MANAGEMENT
 
421
        FileSettingsBase * file_settings;
 
422
        #else
 
423
        QSettings * file_settings;
 
424
        #endif
 
425
#endif
 
426
 
 
427
#ifdef Q_OS_WIN
 
428
#ifdef SCREENSAVER_OFF
 
429
        WinScreenSaver * win_screensaver;
 
430
#endif
 
431
#endif
 
432
    
 
433
private:
 
434
        // Some variables to proper restart
 
435
        bool we_are_restarting;
 
436
 
 
437
        bool just_loaded_external_subs;
 
438
        bool just_unloaded_external_subs;
 
439
        State _state;
 
440
        bool change_volume_after_unpause;
 
441
 
 
442
        QString initial_subtitle;
 
443
};
 
444
    
 
445
#endif