source: smplayer/trunk/src/core.h

Last change on this file was 188, checked in by Silvan Scherrer, 8 years ago

SMPlayer: update trunk to version 17.1.0

  • Property svn:eol-style set to LF
File size: 13.6 KB
Line 
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 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 "playerprocess.h"
27
28#include "config.h"
29
30class FileSettingsBase;
31
32class PlayerProcess;
33class MplayerWindow;
34class QSettings;
35
36#ifdef SCREENSAVER_OFF
37class WinScreenSaver;
38#endif
39
40#ifdef YOUTUBE_SUPPORT
41class RetrieveYoutubeUrl;
42#endif
43
44class Core : public QObject
45{
46 Q_OBJECT
47
48public:
49 enum State { Stopped = 0, Playing = 1, Paused = 2, Buffering = 3 };
50
51 Core( MplayerWindow *mpw, QWidget* parent = 0 );
52 ~Core();
53
54 MediaData mdat;
55 MediaSettings mset;
56
57 //! Return the current state
58 State state() { return _state; };
59
60 //! Return a string with the name of the current state,
61 //! so it can be printed on debugging messages.
62 QString stateToString();
63
64 void addForcedTitle(const QString & file, const QString & title) { forced_titles[file] = title; };
65
66protected:
67 //! Change the current state (Stopped, Playing or Paused)
68 //! And sends the stateChanged() signal.
69 void setState(State s);
70
71public slots:
72 //! Generic open, with autodetection of type
73 void open(QString file, int seek=-1);
74 void openFile(QString filename, int seek=-1);
75 void openStream(QString name, QStringList params = QStringList());
76 /*
77 void openDVD( bool from_folder, QString directory = "");
78 void openDVD(); // Plays title 1
79 void openDVD(int title = 1);
80 */
81 void openDVD(QString dvd_url);
82#ifdef BLURAY_SUPPORT
83 void openBluRay(QString blu_ray_url);
84#endif
85 void openVCD(int title = -1);
86 void openAudioCD(int title = -1);
87#ifdef TV_SUPPORT
88 void openTV(QString channel_id);
89#endif
90
91#ifdef YOUTUBE_SUPPORT
92 void openYT(const QString & url);
93#endif
94
95 void loadSub(const QString & sub);
96 void unloadSub();
97
98 //! Forces to use the specified subtitle file. It's not loaded immediately but stored
99 //! and will be used for the next video. After that the variable is cleared.
100 void setInitialSubtitle(const QString & subtitle_file) { initial_subtitle = subtitle_file; };
101
102 void loadAudioFile(const QString & audiofile);
103 void unloadAudioFile();
104
105 void stop();
106 void play();
107 void play_or_pause();
108 void pause_and_frame_step();
109 void pause();
110 void frameStep();
111 void frameBackStep();
112 void screenshot(); //!< Take a screenshot of current frame
113 void screenshots(); //!< Start/stop taking screenshot of each frame
114#ifdef CAPTURE_STREAM
115 void switchCapturing();
116#endif
117
118 //! Public restart, for the GUI.
119 void restart();
120
121 //! Reopens the file (no restart)
122 void reload();
123
124#ifdef SEEKBAR_RESOLUTION
125 void goToPosition( int value );
126 void goToPos( double perc );
127#else
128 void goToPos( int perc );
129#endif
130 void goToSec( double sec );
131 void goToSec(int sec) { goToSec( (double) sec); }
132
133 void setAMarker(); //!< Set A marker to current sec
134 void setAMarker(int sec);
135
136 void setBMarker(); //!< Set B marker to current sec
137 void setBMarker(int sec);
138
139 void clearABMarkers();
140
141 void toggleRepeat();
142 void toggleRepeat(bool b);
143
144 void toggleFlip();
145 void toggleFlip(bool b);
146
147 void toggleMirror();
148 void toggleMirror(bool b);
149
150 // Audio filters
151#ifdef MPLAYER_SUPPORT
152 void toggleKaraoke();
153 void toggleKaraoke(bool b);
154#endif
155 void toggleExtrastereo();
156 void toggleExtrastereo(bool b);
157
158 void toggleVolnorm();
159 void toggleVolnorm(bool b);
160
161 void setAudioChannels(int channels);
162 void setStereoMode(int mode);
163
164 // Video filters
165 void toggleAutophase();
166 void toggleAutophase(bool b);
167 void toggleDeblock();
168 void toggleDeblock(bool b);
169 void toggleDering();
170 void toggleDering(bool b);
171 void toggleGradfun();
172 void toggleGradfun(bool b);
173 void toggleNoise();
174 void toggleNoise(bool b);
175 void togglePostprocessing();
176 void togglePostprocessing(bool b);
177 void changeDenoise(int);
178 void changeUnsharp(int);
179 void changeLetterbox(bool);
180#ifdef ADD_BLACKBORDERS_FS
181 void changeLetterboxOnFullscreen(bool);
182#endif
183 void changeUpscale(bool);
184 void changeStereo3d(const QString & in, const QString & out);
185
186 void seek(int secs);
187 void sforward(); // + 10 seconds
188 void srewind(); // - 10 seconds
189 void forward(); // + 1 minute
190 void rewind(); // -1 minute
191 void fastforward(); // + 10 minutes
192 void fastrewind(); // - 10 minutes
193 void forward(int secs);
194 void rewind(int secs);
195#ifdef MPV_SUPPORT
196 void seekToNextSub();
197 void seekToPrevSub();
198#endif
199 void wheelUp();
200 void wheelDown();
201
202 void setSpeed( double value );
203 void incSpeed10(); //!< Inc speed 10%
204 void decSpeed10(); //!< Dec speed 10%
205 void incSpeed4(); //!< Inc speed 4%
206 void decSpeed4(); //!< Dec speed 4%
207 void incSpeed1(); //!< Inc speed 1%
208 void decSpeed1(); //!< Dec speed 1%
209 void doubleSpeed();
210 void halveSpeed();
211 void normalSpeed();
212
213 void setVolume(int volume, bool force = false);
214 void switchMute();
215 void mute(bool b);
216 void incVolume(int step);
217 void decVolume(int step);
218 void incVolume();
219 void decVolume();
220
221 void setBrightness(int value);
222 void setContrast(int value);
223 void setGamma(int value);
224 void setHue(int value);
225 void setSaturation(int value);
226
227 void incBrightness();
228 void decBrightness();
229 void incContrast();
230 void decContrast();
231 void incGamma();
232 void decGamma();
233 void incHue();
234 void decHue();
235 void incSaturation();
236 void decSaturation();
237
238 void setSubDelay(int delay);
239 void incSubDelay();
240 void decSubDelay();
241
242 void setAudioDelay(int delay);
243 void incAudioDelay();
244 void decAudioDelay();
245
246 void incSubPos();
247 void decSubPos();
248
249 void changeSubScale(double value);
250 void incSubScale();
251 void decSubScale();
252
253 void changeOSDScale(double value);
254 void incOSDScale();
255 void decOSDScale();
256
257 //! Select next line in subtitle file
258 void incSubStep();
259 //! Select previous line in subtitle file
260 void decSubStep();
261
262 void changeSubVisibility(bool visible);
263
264 void changeExternalSubFPS(int fps_id);
265
266 //! Audio equalizer
267 void setAudioEqualizer(AudioEqualizerList values, bool restart = false);
268 void setAudioAudioEqualizerRestart(AudioEqualizerList values) { setAudioEqualizer(values, true); };
269 void updateAudioEqualizer();
270
271 void setAudioEq(int eq, int value);
272 void setAudioEq0(int value);
273 void setAudioEq1(int value);
274 void setAudioEq2(int value);
275 void setAudioEq3(int value);
276 void setAudioEq4(int value);
277 void setAudioEq5(int value);
278 void setAudioEq6(int value);
279 void setAudioEq7(int value);
280 void setAudioEq8(int value);
281 void setAudioEq9(int value);
282
283 void changeDeinterlace(int);
284 void changeSubtitle(int);
285 void nextSubtitle();
286#ifdef MPV_SUPPORT
287 void changeSecondarySubtitle(int);
288#endif
289 void changeAudio(int ID, bool allow_restart = true);
290 void nextAudio();
291 void changeVideo(int ID, bool allow_restart = true);
292 void nextVideo();
293#if PROGRAM_SWITCH
294 void changeProgram(int ID);
295 void nextProgram();
296#endif
297 void changeTitle(int);
298 void changeChapter(int);
299 void prevChapter();
300 void nextChapter();
301 void changeAngle(int);
302 void changeAspectRatio(int);
303 void nextAspectRatio();
304 void changeOSD(int);
305 void nextOSD();
306 void nextWheelFunction();
307
308#ifdef BOOKMARKS
309 void nextBookmark();
310 void prevBookmark();
311#endif
312
313 #if 0
314 void changeSize(int); // Size of the window
315 void toggleDoubleSize();
316 #endif
317 void changeZoom(double); // Zoom on mplayerwindow
318
319 void changeRotate(int r);
320
321#if USE_ADAPTER
322 void changeAdapter(int n);
323#endif
324
325 void changeAO(const QString & new_ao);
326
327 void incZoom();
328 void decZoom();
329 void resetZoom();
330 void autoZoom();
331 void autoZoomFromLetterbox(double video_aspect);
332 void autoZoomFor169();
333 void autoZoomFor235();
334
335 void showFilenameOnOSD();
336 void showTimeOnOSD();
337 void toggleDeinterlace();
338
339 void changeUseCustomSubStyle(bool);
340 void toggleForcedSubsOnly(bool);
341
342 void changeClosedCaptionChannel(int);
343 /*
344 void nextClosedCaptionChannel();
345 void prevClosedCaptionChannel();
346 */
347
348#if DVDNAV_SUPPORT
349 // dvdnav buttons
350 void dvdnavUp();
351 void dvdnavDown();
352 void dvdnavLeft();
353 void dvdnavRight();
354 void dvdnavMenu();
355 void dvdnavSelect();
356 void dvdnavPrev();
357 void dvdnavMouse();
358#endif
359
360 //! Change fullscreen when using the player own window
361 void changeFullscreenMode(bool b);
362
363 //! Wrapper for the osd_show_text slave command
364 void displayTextOnOSD(QString text, int duration = 3000, int level = 1,
365 QString prefix = QString::null);
366
367public:
368 //! Returns the number of the first chapter in
369 //! files. In some versions of mplayer is 0, in others 1
370 static int firstChapter();
371 int firstDVDTitle();
372 int firstBlurayTitle();
373
374 void changeFileSettingsMethod(QString method);
375
376protected:
377 //! Returns the prefix to keep pausing on slave commands
378 QString pausing_prefix();
379 void seek_cmd(double secs, int mode);
380
381protected slots:
382 void changeCurrentSec(double sec);
383 void changePause();
384 void gotWindowResolution( int w, int h );
385 void gotNoVideo();
386 void gotVO(QString);
387 void gotAO(QString);
388 void gotStartingTime(double);
389 void gotVideoBitrate(int);
390 void gotAudioBitrate(int);
391
392 void finishRestart();
393 void processFinished();
394 void fileReachedEnd();
395
396 void displayMessage(QString text);
397 void displayScreenshotName(QString filename);
398 void displayUpdatingFontCache();
399 void displayBuffering();
400 void displayPlaying();
401
402 void streamTitleChanged(QString);
403 void streamTitleAndUrlChanged(QString,QString);
404
405 // Catches mediaInfoChanged and sends mediaPlaying signal
406 void sendMediaInfo();
407
408 void watchState(Core::State state);
409
410 //! Called when a video has just started to play.
411 //! This function checks if the codec of video is ffh264 and if
412 //! the resolution is HD
413 void checkIfVideoIsHD();
414
415#if DELAYED_AUDIO_SETUP_ON_STARTUP
416 void initAudioTrack();
417#endif
418#if NOTIFY_AUDIO_CHANGES
419 void initAudioTrack(const Tracks &);
420#endif
421#if NOTIFY_VIDEO_CHANGES
422 void initVideoTrack(const Tracks &);
423#endif
424#if NOTIFY_SUB_CHANGES
425 void initSubtitleTrack(const SubTracks &);
426 void setSubtitleTrackAgain(const SubTracks &);
427#endif
428#if NOTIFY_CHAPTER_CHANGES
429 void updateChapterInfo(const Chapters &);
430#endif
431
432#if DVDNAV_SUPPORT
433 void dvdTitleChanged(int);
434 void durationChanged(double);
435 void askForInfo();
436 void dvdnavUpdateMousePos(QPoint);
437 void dvdTitleIsMenu();
438 void dvdTitleIsMovie();
439#endif
440
441 void initializeOSD();
442
443#ifdef YOUTUBE_SUPPORT
444 void connectingToYT(QString host);
445 void YTFailed(int error_number, QString error_str);
446 void YTNoVideoUrl();
447#endif
448
449#ifdef SCREENSAVER_OFF
450 void enableScreensaver();
451 void disableScreensaver();
452#endif
453
454protected:
455 void playNewFile(QString file, int seek=-1);
456 void restartPlay();
457 void initPlaying(int seek=-1);
458 void newMediaPlaying();
459
460 void startMplayer(QString file, double seek = -1 );
461 void stopMplayer();
462
463 void saveMediaInfo();
464 void restoreSettingsForMedia(const QString & name, int type);
465
466 void initializeMenus();
467 void updateWidgets();
468
469 //! Returns true if changing the subscale requires to restart mplayer
470 bool subscale_need_restart();
471
472 int adjustVolume(int v, int max_vol);
473
474signals:
475 void buffering();
476 void aboutToStartPlaying(); // Signal emited just before to start mplayer
477 void mediaLoaded();
478 void mediaInfoChanged();
479 void mediaDataReceived(const MediaData &);
480 //! Sends the filename and title of the stream playing in this moment
481 void mediaPlaying(const QString & filename, const QString & title);
482 void stateChanged(Core::State state);
483 void mediaStartPlay();
484 void mediaFinished(); // Media has arrived to the end.
485 void mediaStoppedByUser();
486 void showMessage(QString text);
487 void showMessage(QString text, int time);
488 void menusNeedInitialize();
489 void widgetsNeedUpdate();
490 void videoEqualizerNeedsUpdate();
491 void audioEqualizerNeedsUpdate();
492 void showTime(double sec);
493#ifdef SEEKBAR_RESOLUTION
494 void positionChanged(int); // To connect a slider
495#else
496 void posChanged(int); // To connect a slider
497#endif
498 void newDuration(double); // Duration has changed
499 void showFrame(int frame);
500 void ABMarkersChanged(int secs_a, int secs_b);
501 void bitrateChanged(int vbitrate, int abitrate);
502 void needResize(int w, int h);
503 void noVideo();
504 void volumeChanged(int);
505#if NOTIFY_AUDIO_CHANGES
506 void audioTracksChanged();
507#endif
508
509 //! Sent when requested to play, but there is no file to play
510 void noFileToPlay();
511
512 //! MPlayer started but finished with exit code != 0
513 void mplayerFinishedWithError(int exitCode);
514
515 //! MPlayer didn't started or crashed
516 void mplayerFailed(QProcess::ProcessError error);
517
518 // Resend signal from mplayerprocess:
519 void failedToParseMplayerVersion(QString line_with_mplayer_version);
520
521 //! A new line from the mplayer output is available
522 void logLineAvailable(QString);
523
524#ifdef YOUTUBE_SUPPORT
525 void signatureNotFound(const QString &);
526 void noSslSupport();
527#endif
528
529 void receivedForbidden();
530
531protected:
532 PlayerProcess * proc;
533 MplayerWindow * mplayerwindow;
534
535 FileSettingsBase * file_settings;
536#ifdef TV_SUPPORT
537 FileSettingsBase * tv_settings;
538#endif
539
540#ifdef SCREENSAVER_OFF
541 WinScreenSaver * win_screensaver;
542#endif
543
544#ifdef YOUTUBE_SUPPORT
545 RetrieveYoutubeUrl * yt;
546#endif
547
548private:
549 // Some variables to proper restart
550 bool we_are_restarting;
551
552 bool just_loaded_external_subs;
553 bool just_unloaded_external_subs;
554 State _state;
555 bool change_volume_after_unpause;
556
557 QString initial_subtitle;
558
559#if DVDNAV_SUPPORT
560 bool dvdnav_title_is_menu;
561#endif
562
563 QMap<QString,QString> forced_titles;
564};
565
566#endif
Note: See TracBrowser for help on using the repository browser.