source: smplayer/trunk/src/core.h@ 139

Last change on this file since 139 was 128, checked in by Silvan Scherrer, 14 years ago

SMPlayer: trunk update to latest svn

  • Property svn:eol-style set to LF
File size: 12.0 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2012 Ricardo Villalba <[email protected]>
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#ifndef NO_USE_INI_FILES
30class FileSettingsBase;
31#endif
32
33class MplayerProcess;
34class MplayerWindow;
35class QSettings;
36
37#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
38#ifdef SCREENSAVER_OFF
39class WinScreenSaver;
40#endif
41#endif
42
43#ifdef YOUTUBE_SUPPORT
44class RetrieveYoutubeUrl;
45#endif
46
47class Core : public QObject
48{
49 Q_OBJECT
50
51public:
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
67protected:
68 //! Change the current state (Stopped, Playing or Paused)
69 //! And sends the stateChanged() signal.
70 void setState(State s);
71
72public 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 void openTV(QString channel_id);
86
87#ifdef YOUTUBE_SUPPORT
88 void openYT(const QString & url);
89#endif
90
91 void loadSub(const QString & sub);
92 void unloadSub();
93
94 //! Forces to use the specified subtitle file. It's not loaded immediately but stored
95 //! and will be used for the next video. After that the variable is cleared.
96 void setInitialSubtitle(const QString & subtitle_file) { initial_subtitle = subtitle_file; };
97
98 void loadAudioFile(const QString & audiofile);
99 void unloadAudioFile();
100
101 void stop();
102 void play();
103 void play_or_pause();
104 void pause_and_frame_step();
105 void pause();
106 void frameStep();
107 void screenshot(); //!< Take a screenshot of current frame
108 void screenshots(); //!< Start/stop taking screenshot of each frame
109
110 //! Public restart, for the GUI.
111 void restart();
112
113 //! Reopens the file (no restart)
114 void reload();
115
116#ifdef SEEKBAR_RESOLUTION
117 void goToPosition( int value );
118 void goToPos( double perc );
119#else
120 void goToPos( int perc );
121#endif
122 void goToSec( double sec );
123
124 void setAMarker(); //!< Set A marker to current sec
125 void setAMarker(int sec);
126
127 void setBMarker(); //!< Set B marker to current sec
128 void setBMarker(int sec);
129
130 void clearABMarkers();
131
132 void toggleRepeat();
133 void toggleRepeat(bool b);
134
135 void toggleFlip();
136 void toggleFlip(bool b);
137
138 void toggleMirror();
139 void toggleMirror(bool b);
140
141 // Audio filters
142 void toggleKaraoke();
143 void toggleKaraoke(bool b);
144 void toggleExtrastereo();
145 void toggleExtrastereo(bool b);
146 void toggleVolnorm();
147 void toggleVolnorm(bool b);
148
149 void setAudioChannels(int channels);
150 void setStereoMode(int mode);
151
152 // Video filters
153 void toggleAutophase();
154 void toggleAutophase(bool b);
155 void toggleDeblock();
156 void toggleDeblock(bool b);
157 void toggleDering();
158 void toggleDering(bool b);
159 void toggleGradfun();
160 void toggleGradfun(bool b);
161 void toggleNoise();
162 void toggleNoise(bool b);
163 void togglePostprocessing();
164 void togglePostprocessing(bool b);
165 void changeDenoise(int);
166 void changeUnsharp(int);
167 void changeLetterbox(bool);
168 void changeUpscale(bool);
169
170 void seek(int secs);
171 void sforward(); // + 10 seconds
172 void srewind(); // - 10 seconds
173 void forward(); // + 1 minute
174 void rewind(); // -1 minute
175 void fastforward(); // + 10 minutes
176 void fastrewind(); // - 10 minutes
177 void forward(int secs);
178 void rewind(int secs);
179 void wheelUp();
180 void wheelDown();
181
182 void setSpeed( double value );
183 void incSpeed10(); //!< Inc speed 10%
184 void decSpeed10(); //!< Dec speed 10%
185 void incSpeed4(); //!< Inc speed 4%
186 void decSpeed4(); //!< Dec speed 4%
187 void incSpeed1(); //!< Inc speed 1%
188 void decSpeed1(); //!< Dec speed 1%
189 void doubleSpeed();
190 void halveSpeed();
191 void normalSpeed();
192
193 void setVolume(int volume, bool force = false);
194 void switchMute();
195 void mute(bool b);
196 void incVolume();
197 void decVolume();
198
199 void setBrightness(int value);
200 void setContrast(int value);
201 void setGamma(int value);
202 void setHue(int value);
203 void setSaturation(int value);
204
205 void incBrightness();
206 void decBrightness();
207 void incContrast();
208 void decContrast();
209 void incGamma();
210 void decGamma();
211 void incHue();
212 void decHue();
213 void incSaturation();
214 void decSaturation();
215
216 void setSubDelay(int delay);
217 void incSubDelay();
218 void decSubDelay();
219
220 void setAudioDelay(int delay);
221 void incAudioDelay();
222 void decAudioDelay();
223
224 void incSubPos();
225 void decSubPos();
226
227 void changeSubScale(double value);
228 void incSubScale();
229 void decSubScale();
230
231 //! Select next line in subtitle file
232 void incSubStep();
233 //! Select previous line in subtitle file
234 void decSubStep();
235
236 void changeSubVisibility(bool visible);
237
238 //! Audio equalizer
239 void setAudioEqualizer(AudioEqualizerList values, bool restart = false);
240 void setAudioAudioEqualizerRestart(AudioEqualizerList values) { setAudioEqualizer(values, true); };
241 void updateAudioEqualizer();
242
243 void setAudioEq0(int value);
244 void setAudioEq1(int value);
245 void setAudioEq2(int value);
246 void setAudioEq3(int value);
247 void setAudioEq4(int value);
248 void setAudioEq5(int value);
249 void setAudioEq6(int value);
250 void setAudioEq7(int value);
251 void setAudioEq8(int value);
252 void setAudioEq9(int value);
253
254 void changeDeinterlace(int);
255 void changeSubtitle(int);
256 void nextSubtitle();
257 void changeAudio(int ID, bool allow_restart = true);
258 void nextAudio();
259 void changeVideo(int ID, bool allow_restart = true);
260 void nextVideo();
261#if PROGRAM_SWITCH
262 void changeProgram(int ID);
263 void nextProgram();
264#endif
265 void changeTitle(int);
266 void changeChapter(int);
267 void prevChapter();
268 void nextChapter();
269 void changeAngle(int);
270 void changeAspectRatio(int);
271 void nextAspectRatio();
272 void changeOSD(int);
273 void nextOSD();
274 void nextWheelFunction();
275
276 void changeSize(int); // Size of the window
277 void toggleDoubleSize();
278 void changeZoom(double); // Zoom on mplayerwindow
279
280 void changeRotate(int r);
281
282#if USE_ADAPTER
283 void changeAdapter(int n);
284#endif
285
286 void incZoom();
287 void decZoom();
288 void resetZoom();
289 void autoZoom();
290 void autoZoomFromLetterbox(double video_aspect);
291 void autoZoomFor169();
292 void autoZoomFor235();
293
294#if USE_MPLAYER_PANSCAN
295 void changePanscan(double);
296 void incPanscan();
297 void decPanscan();
298#endif
299
300 void showFilenameOnOSD();
301 void toggleDeinterlace();
302
303 void changeUseAss(bool);
304 void toggleForcedSubsOnly(bool);
305
306 void changeClosedCaptionChannel(int);
307 /*
308 void nextClosedCaptionChannel();
309 void prevClosedCaptionChannel();
310 */
311
312#if DVDNAV_SUPPORT
313 // dvdnav buttons
314 void dvdnavUp();
315 void dvdnavDown();
316 void dvdnavLeft();
317 void dvdnavRight();
318 void dvdnavMenu();
319 void dvdnavSelect();
320 void dvdnavPrev();
321 void dvdnavMouse();
322#endif
323
324 // Pass a command to mplayer by stdin:
325 void tellmp(const QString & command);
326
327 //! Wrapper for the osd_show_text slave command
328 void displayTextOnOSD(QString text, int duration = 3000, int level = 1,
329 QString prefix = QString::null);
330
331public:
332 //! Returns the number of the first chapter in
333 //! files. In some versions of mplayer is 0, in others 1
334 static int firstChapter();
335
336#ifndef NO_USE_INI_FILES
337 void changeFileSettingsMethod(QString method);
338#endif
339
340protected:
341 //! Returns the prefix to keep pausing on slave commands
342 QString pausing_prefix();
343 QString seek_cmd(double secs, int mode);
344
345protected slots:
346 void changeCurrentSec(double sec);
347 void changePause();
348 void gotWindowResolution( int w, int h );
349 void gotNoVideo();
350 void gotVO(QString);
351 void gotAO(QString);
352 void gotStartingTime(double);
353
354 void finishRestart();
355 void processFinished();
356 void fileReachedEnd();
357
358 void displayMessage(QString text);
359 void displayScreenshotName(QString filename);
360 void displayUpdatingFontCache();
361
362 void streamTitleChanged(QString);
363 void streamTitleAndUrlChanged(QString,QString);
364
365 // Catches mediaInfoChanged and sends mediaPlaying signal
366 void sendMediaInfo();
367
368 void watchState(Core::State state);
369
370 //! Called when a video has just started to play.
371 //! This function checks if the codec of video is ffh264 and if
372 //! the resolution is HD
373 void checkIfVideoIsHD();
374
375#if DELAYED_AUDIO_SETUP_ON_STARTUP
376 void initAudioTrack();
377#endif
378#if NOTIFY_AUDIO_CHANGES
379 void initAudioTrack(const Tracks &);
380#endif
381#if NOTIFY_SUB_CHANGES
382 void initSubtitleTrack(const SubTracks &);
383 void setSubtitleTrackAgain(const SubTracks &);
384#endif
385#if DVDNAV_SUPPORT
386 void dvdTitleChanged(int);
387 void durationChanged(double);
388 void askForInfo();
389 void dvdnavUpdateMousePos(QPoint);
390 void dvdTitleIsMenu();
391 void dvdTitleIsMovie();
392#endif
393
394 void initializeOSD();
395
396#ifdef YOUTUBE_SUPPORT
397 void connectingToYT(QString host);
398 void YTFailed(QString error);
399 void YTNoVideoUrl();
400#endif
401
402protected:
403 void playNewFile(QString file, int seek=-1);
404 void restartPlay();
405 void initPlaying(int seek=-1);
406 void newMediaPlaying();
407
408 void startMplayer(QString file, double seek = -1 );
409 void stopMplayer();
410
411#ifndef NO_USE_INI_FILES
412 void saveMediaInfo();
413#endif
414
415 void initializeMenus();
416 void updateWidgets();
417
418 //! Returns true if changing the subscale requires to restart mplayer
419 bool subscale_need_restart();
420
421signals:
422 void aboutToStartPlaying(); // Signal emited just before to start mplayer
423 void mediaLoaded();
424 void mediaInfoChanged();
425 //! Sends the filename and title of the stream playing in this moment
426 void mediaPlaying(const QString & filename, const QString & title);
427 void stateChanged(Core::State state);
428 void mediaStartPlay();
429 void mediaFinished(); // Media has arrived to the end.
430 void mediaStoppedByUser();
431 void showMessage(QString text);
432 void menusNeedInitialize();
433 void widgetsNeedUpdate();
434 void videoEqualizerNeedsUpdate();
435 void audioEqualizerNeedsUpdate();
436 void showTime(double sec);
437#ifdef SEEKBAR_RESOLUTION
438 void positionChanged(int); // To connect a slider
439#else
440 void posChanged(int); // To connect a slider
441#endif
442 void showFrame(int frame);
443 void ABMarkersChanged(int secs_a, int secs_b);
444 void needResize(int w, int h);
445 void noVideo();
446 void volumeChanged(int);
447#if NOTIFY_AUDIO_CHANGES
448 void audioTracksChanged();
449#endif
450
451 //! MPlayer started but finished with exit code != 0
452 void mplayerFinishedWithError(int exitCode);
453
454 //! MPlayer didn't started or crashed
455 void mplayerFailed(QProcess::ProcessError error);
456
457 // Resend signal from mplayerprocess:
458 void failedToParseMplayerVersion(QString line_with_mplayer_version);
459
460 //! A new line from the mplayer output is available
461 void logLineAvailable(QString);
462
463protected:
464 MplayerProcess * proc;
465 MplayerWindow * mplayerwindow;
466
467#ifndef NO_USE_INI_FILES
468 FileSettingsBase * file_settings;
469 FileSettingsBase * tv_settings;
470#endif
471
472#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
473#ifdef SCREENSAVER_OFF
474 WinScreenSaver * win_screensaver;
475#endif
476#endif
477
478#ifdef YOUTUBE_SUPPORT
479 RetrieveYoutubeUrl * yt;
480#endif
481
482private:
483 // Some variables to proper restart
484 bool we_are_restarting;
485
486 bool just_loaded_external_subs;
487 bool just_unloaded_external_subs;
488 State _state;
489 bool change_volume_after_unpause;
490
491 QString initial_subtitle;
492
493#if DVDNAV_SUPPORT
494 bool dvdnav_title_is_menu;
495#endif
496};
497
498#endif
Note: See TracBrowser for help on using the repository browser.