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