diff options
author | Mateusz Łukasik <mati75@linuxmint.pl> | 2015-04-25 16:17:41 +0200 |
---|---|---|
committer | Mateusz Łukasik <mati75@linuxmint.pl> | 2015-04-25 16:17:41 +0200 |
commit | 45ee5ac6dc2159352596ce8e8ec744e0c864d492 (patch) | |
tree | 55ca90fd4a0d5c0eae188c5919510b6b0d2e3c5d /src/core.cpp | |
parent | a35c74c509f107094fd81cee8df109b652063969 (diff) |
Imported Upstream version 14.9.0.6690~ds0
Diffstat (limited to 'src/core.cpp')
-rw-r--r-- | src/core.cpp | 1228 |
1 files changed, 595 insertions, 633 deletions
diff --git a/src/core.cpp b/src/core.cpp index ef6f806..ac5e568 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -1,5 +1,5 @@ /* smplayer, GUI front-end for mplayer. - Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net> + Copyright (C) 2006-2015 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 @@ -22,6 +22,7 @@ #include <QRegExp> #include <QTextStream> #include <QUrl> +#include <QNetworkProxy> #ifdef Q_OS_OS2 #include <QEventLoop> @@ -94,7 +95,7 @@ Core::Core( MplayerWindow *mpw, QWidget* parent ) tv_settings = new TVSettings(Paths::iniPath()); #endif - proc = new MplayerProcess(this); + proc = PlayerProcess::createPlayerProcess(pref->mplayer_bin); // Do this the first connect( proc, SIGNAL(processExited()), @@ -137,6 +138,12 @@ Core::Core( MplayerWindow *mpw, QWidget* parent ) this, SIGNAL(buffering())); */ + connect( proc, SIGNAL(receivedBuffering()), + this, SIGNAL(buffering())); + + connect( proc, SIGNAL(receivedPlaying()), + this, SLOT(displayPlaying())); + connect( proc, SIGNAL(receivedCacheEmptyMessage(QString)), this, SIGNAL(buffering())); @@ -208,6 +215,15 @@ Core::Core( MplayerWindow *mpw, QWidget* parent ) connect( proc, SIGNAL(audioInfoChanged(const Tracks &)), this, SLOT(initAudioTrack(const Tracks &)), Qt::QueuedConnection ); #endif +#if NOTIFY_VIDEO_CHANGES + connect( proc, SIGNAL(videoInfoChanged(const Tracks &)), + this, SLOT(initVideoTrack(const Tracks &)), Qt::QueuedConnection ); +#endif +#if NOTIFY_CHAPTER_CHANGES + connect( proc, SIGNAL(chaptersChanged(const Chapters &)), + this, SLOT(updateChapterInfo(const Chapters &)), Qt::QueuedConnection ); +#endif + #if DVDNAV_SUPPORT connect( proc, SIGNAL(receivedDVDTitle(int)), this, SLOT(dvdTitleChanged(int)), Qt::QueuedConnection ); @@ -273,7 +289,7 @@ Core::Core( MplayerWindow *mpw, QWidget* parent ) connect(yt, SIGNAL(gotPreferredUrl(const QString &)), this, SLOT(openYT(const QString &))); connect(yt, SIGNAL(connecting(QString)), this, SLOT(connectingToYT(QString))); connect(yt, SIGNAL(errorOcurred(int,QString)), this, SLOT(YTFailed(int,QString))); - /* connect(yt, SIGNAL(signatureNotFound()), this, SLOT(YTNoSignature())); */ + connect(yt, SIGNAL(noSslSupport()), this, SIGNAL(noSslSupport())); connect(yt, SIGNAL(signatureNotFound(const QString&)), this, SIGNAL(signatureNotFound(const QString&))); connect(yt, SIGNAL(gotEmptyList()), this, SLOT(YTNoVideoUrl())); #endif @@ -365,11 +381,11 @@ void Core::saveMediaInfo() { } if ( (mdat.type == TYPE_FILE) && (!mdat.filename.isEmpty()) ) { - file_settings->saveSettingsFor(mdat.filename, mset); + file_settings->saveSettingsFor(mdat.filename, mset, proc->player()); } else if ( (mdat.type == TYPE_TV) && (!mdat.filename.isEmpty()) ) { - tv_settings->saveSettingsFor(mdat.filename, mset); + tv_settings->saveSettingsFor(mdat.filename, mset, proc->player()); } } #endif // NO_USE_INI_FILES @@ -388,25 +404,16 @@ void Core::updateWidgets() { } -void Core::tellmp(const QString & command) { - qDebug("Core::tellmp: '%s'", command.toUtf8().data()); - - //qDebug("Command: '%s'", command.toUtf8().data()); - if (proc->isRunning()) { - proc->writeToStdin( command ); - } else { - qWarning(" tellmp: no process running: %s", command.toUtf8().data()); - } +void Core::changeFullscreenMode(bool b) { + proc->setFullscreen(b); } void Core::displayTextOnOSD(QString text, int duration, int level, QString prefix) { qDebug("Core::displayTextOnOSD: '%s'", text.toUtf8().constData()); if (proc->isRunning()) { - QString str = QString("osd_show_text \"%1\" %2 %3\n").arg(text.toUtf8().constData()).arg(duration).arg(level); - if (!prefix.isEmpty()) str = prefix + " " + str; - qDebug("Core::displayTextOnOSD: command: '%s'", str.toUtf8().constData()); - proc->write(str.toLatin1()); + proc->setPausingPrefix(prefix); + proc->showOSDText(text, duration, level); } } @@ -426,7 +433,7 @@ void Core::open(QString file, int seek) { #if DVDNAV_SUPPORT openDVD( DiscName::joinDVD(0, file, pref->use_dvdnav) ); #else - openDVD( DiscName::joinDVD(1, file, false) ); + openDVD( DiscName::joinDVD(firstDVDTitle(), file, false) ); #endif } else @@ -445,9 +452,9 @@ void Core::open(QString file, int seek) { if (Helper::directoryContainsDVD(file)) { qDebug("Core::open: * directory contains a dvd"); #if DVDNAV_SUPPORT - openDVD( DiscName::joinDVD(1, file, pref->use_dvdnav) ); + openDVD( DiscName::joinDVD(firstDVDTitle(), file, pref->use_dvdnav) ); #else - openDVD( DiscName::joinDVD(1, file, false) ); + openDVD( DiscName::joinDVD(firstDVDTitle(), file, false) ); #endif } else { qDebug("Core::open: * directory doesn't contain a dvd"); @@ -543,12 +550,6 @@ void Core::YTFailed(int /*error_number*/, QString /*error_str*/) { emit showMessage( tr("Unable to retrieve the Youtube page") ); } -/* -void Core::YTNoSignature() { - emit showMessage( tr("Video protected. It can't be played."), 5000 ); -} -*/ - void Core::YTNoVideoUrl() { emit showMessage( tr("Unable to locate the URL of the video") ); } @@ -579,7 +580,10 @@ void Core::loadSub(const QString & sub ) { just_loaded_external_subs = true; QFileInfo fi(sub); - if ((pref->fast_load_sub) && (fi.suffix().toLower() != "idx") && (mset.external_subtitles_fps == MediaSettings::SFPS_None)) { + bool is_idx = (fi.suffix().toLower() == "idx"); + if (proc->isMPV()) is_idx = false; // Hack to ignore the idx extension with mpv + + if ((pref->fast_load_sub) && (!is_idx) && (mset.external_subtitles_fps == MediaSettings::SFPS_None)) { QString sub_file = sub; #ifdef Q_OS_WIN if (pref->use_short_pathnames) { @@ -589,7 +593,7 @@ void Core::loadSub(const QString & sub ) { sub_file = sub_file.replace("\\","/"); } #endif - tellmp( "sub_load \""+ sub_file +"\"" ); + proc->setExternalSubtitleFile(sub_file); } else { restartPlay(); } @@ -877,7 +881,7 @@ void Core::openTV(QString channel_id) { qDebug("Core::openTV: we have settings for this file!!!"); // In this case we read info from config - tv_settings->loadSettingsFor(channel_id, mset); + tv_settings->loadSettingsFor(channel_id, mset, proc->player()); qDebug("Core::openTV: media settings read"); } } @@ -892,20 +896,22 @@ void Core::openStream(QString name) { qDebug("Core::openStream: '%s'", name.toUtf8().data()); #ifdef YOUTUBE_SUPPORT - // Check if the stream is a youtube url - QString yt_full_url = yt->fullUrl(name); - if (!yt_full_url.isEmpty()) { - qDebug("Core::openStream: youtube url detected: %s", yt_full_url.toLatin1().constData()); - name = yt_full_url; - yt->setPreferredQuality( (RetrieveYoutubeUrl::Quality) pref->yt_quality ); - qDebug("Core::openStream: user_agent: '%s'", pref->yt_user_agent.toUtf8().constData()); - /*if (!pref->yt_user_agent.isEmpty()) yt->setUserAgent(pref->yt_user_agent); */ - yt->setUserAgent(pref->yt_user_agent); - #ifdef YT_USE_SCRIPT - YTSig::setScriptFile( Paths::configPath() + "/yt.js" ); - #endif - yt->fetchPage(name); - return; + if (pref->enable_yt_support) { + // Check if the stream is a youtube url + QString yt_full_url = yt->fullUrl(name); + if (!yt_full_url.isEmpty()) { + qDebug("Core::openStream: youtube url detected: %s", yt_full_url.toLatin1().constData()); + name = yt_full_url; + yt->setPreferredQuality( (RetrieveYoutubeUrl::Quality) pref->yt_quality ); + qDebug("Core::openStream: user_agent: '%s'", pref->yt_user_agent.toUtf8().constData()); + /*if (!pref->yt_user_agent.isEmpty()) yt->setUserAgent(pref->yt_user_agent); */ + yt->setUserAgent(pref->yt_user_agent); + #ifdef YT_USE_SCRIPT + YTSig::setScriptFile( Paths::configPath() + "/yt.js" ); + #endif + yt->fetchPage(name); + return; + } } #endif @@ -958,7 +964,7 @@ void Core::playNewFile(QString file, int seek) { // In this case we read info from config if (!pref->dont_remember_media_settings) { - file_settings->loadSettingsFor(file, mset); + file_settings->loadSettingsFor(file, mset, proc->player()); qDebug("Core::playNewFile: Media settings read"); // Resize the window and set the aspect as soon as possible @@ -1024,10 +1030,12 @@ void Core::initPlaying(int seek) { if (seek > -1) start_sec = seek; #ifdef YOUTUBE_SUPPORT - // Avoid to pass to mplayer the youtube page url - if (mdat.type == TYPE_STREAM) { - if (mdat.filename == yt->origUrl()) { - mdat.filename = yt->latestPreferredUrl(); + if (pref->enable_yt_support) { + // Avoid to pass to mplayer the youtube page url + if (mdat.type == TYPE_STREAM) { + if (mdat.filename == yt->origUrl()) { + mdat.filename = yt->latestPreferredUrl(); + } } } #endif @@ -1048,6 +1056,9 @@ void Core::newMediaPlaying() { initializeMenus(); // Old + // Copy the demuxer + mset.current_demuxer = mdat.demuxer; + // Video if ( (mset.current_video_id == MediaSettings::NoneSelected) && (mdat.videos.numItems() > 0) ) @@ -1139,11 +1150,13 @@ void Core::finishRestart() { } #ifdef YOUTUBE_SUPPORT - // Change the real url with the youtube page url and set the title - if (mdat.type == TYPE_STREAM) { - if (mdat.filename == yt->latestPreferredUrl()) { - mdat.filename = yt->origUrl(); - mdat.stream_title = yt->urlTitle(); + if (pref->enable_yt_support) { + // Change the real url with the youtube page url and set the title + if (mdat.type == TYPE_STREAM) { + if (mdat.filename == yt->latestPreferredUrl()) { + mdat.filename = yt->origUrl(); + mdat.stream_title = yt->urlTitle(); + } } } #endif @@ -1200,6 +1213,7 @@ void Core::finishRestart() { // Normal restart, subtitles haven't changed // Recover current subtitle changeSubtitle( mset.current_sub_id ); + changeSecondarySubtitle( mset.current_secondary_sub_id ); } #endif @@ -1221,11 +1235,14 @@ void Core::finishRestart() { } } +#if 0 +// Old. Gamma already set with option -gamma if (pref->change_video_equalizer_on_startup && (mset.gamma != 0)) { int gamma = mset.gamma; mset.gamma = -1000; // if mset.gamma == new value, mset.gamma is not changed! setGamma( gamma ); } +#endif // Hack to be sure that the equalizers are up to date emit videoEqualizerNeedsUpdate(); emit audioEqualizerNeedsUpdate(); @@ -1291,7 +1308,7 @@ void Core::play() { qDebug("Core::play"); if ((proc->isRunning()) && (state()==Paused)) { - tellmp("pause"); // Unpauses + proc->setPause(false); } else if ((proc->isRunning()) && (state()==Playing)) { @@ -1318,21 +1335,19 @@ void Core::pause_and_frame_step() { if (proc->isRunning()) { if (state() == Paused) { - tellmp("frame_step"); - } - else { - tellmp("pause"); + proc->frameStep(); + } else { + proc->setPause(true); } } } void Core::pause() { - qDebug("Core::pause"); qDebug("Core::pause: current state: %s", stateToString().toUtf8().data()); if (proc->isRunning()) { // Pauses and unpauses - tellmp("pause"); + if (state() == Paused) proc->setPause(false); else proc->setPause(true); } } @@ -1348,7 +1363,15 @@ void Core::frameStep() { qDebug("Core::frameStep"); if (proc->isRunning()) { - tellmp("frame_step"); + proc->frameStep(); + } +} + +void Core::frameBackStep() { + qDebug("Core::frameBackStep"); + + if (proc->isRunning()) { + proc->frameBackStep(); } } @@ -1358,7 +1381,8 @@ void Core::screenshot() { if ( (!pref->screenshot_directory.isEmpty()) && (QFileInfo(pref->screenshot_directory).isDir()) ) { - tellmp( pausing_prefix() + " screenshot 0"); + proc->setPausingPrefix(pausing_prefix()); + proc->takeScreenshot(PlayerProcess::Single, pref->subtitles_on_screenshots); qDebug("Core::screenshot: taken screenshot"); } else { qDebug("Core::screenshot: error: directory for screenshots not valid"); @@ -1372,7 +1396,7 @@ void Core::screenshots() { if ( (!pref->screenshot_directory.isEmpty()) && (QFileInfo(pref->screenshot_directory).isDir()) ) { - tellmp( "screenshot 1"); + proc->takeScreenshot(PlayerProcess::Multiple, pref->subtitles_on_screenshots); } else { qDebug("Core::screenshots: error: directory for screenshots not valid"); emit showMessage( tr("Screenshots NOT taken, folder not configured") ); @@ -1432,12 +1456,12 @@ void Core::goToPosition(int value) { void Core::goToPos(double perc) { qDebug("Core::goToPos: per: %f", perc); - tellmp( seek_cmd(perc, 1) ); + seek_cmd(perc, 1); } #else void Core::goToPos(int perc) { qDebug("Core::goToPos: per: %d", perc); - tellmp( seek_cmd(perc, 1) ); + seek_cmd(perc, 1); } #endif @@ -1466,8 +1490,6 @@ void Core::startMplayer( QString file, double seek ) { yt->close(); #endif - bool is_mkv = (QFileInfo(file).suffix().toLower() == "mkv"); - // DVD QString dvd_folder; int dvd_title = -1; @@ -1477,7 +1499,7 @@ void Core::startMplayer( QString file, double seek ) { if (dvd_folder.isEmpty()) dvd_folder = pref->dvd_device; dvd_title = disc_data.title; file = disc_data.protocol + "://"; - if (dvd_title > 0) file += QString::number(dvd_title); + if (dvd_title > -1) file += QString::number(dvd_title); } // Check URL playlist @@ -1546,45 +1568,41 @@ void Core::startMplayer( QString file, double seek ) { } } - proc->addArgument( mplayer_bin ); - - proc->addArgument("-noquiet"); + proc->setExecutable(mplayer_bin); + proc->setFixedOptions(); #ifdef LOG_MPLAYER if (pref->verbose_log) { - proc->addArgument("-v"); + proc->setOption("verbose"); } #endif if (pref->fullscreen && pref->use_mplayer_window) { - proc->addArgument("-fs"); + proc->setOption("fs", true); } else { // No mplayer fullscreen mode -#if !USE_MPLAYER_PANSCAN - proc->addArgument("-nofs"); -#else - // The command 'panscan' requires -fs - proc->addArgument("-fs"); -#endif + proc->setOption("fs", false); } - proc->addArgument("-nomouseinput"); - +#if !ALLOW_DEMUXER_CODEC_CHANGE + if (pref->use_lavf_demuxer) { + proc->setOption("demuxer", "lavf"); + } +#else // Demuxer and audio and video codecs: if (!mset.forced_demuxer.isEmpty()) { - proc->addArgument("-demuxer"); - proc->addArgument(mset.forced_demuxer); + proc->setOption("demuxer", mset.forced_demuxer); } if (!mset.forced_audio_codec.isEmpty()) { - proc->addArgument("-ac"); - proc->addArgument(mset.forced_audio_codec); + proc->setOption("ac", mset.forced_audio_codec); } if (!mset.forced_video_codec.isEmpty()) { - proc->addArgument("-vc"); - proc->addArgument(mset.forced_video_codec); + proc->setOption("vc", mset.forced_video_codec); } -#ifndef Q_OS_WIN - else { + else +#endif + { + #ifndef Q_OS_WIN /* if (pref->vo.startsWith("x11")) { */ // My card doesn't support vdpau, I use x11 to test if (pref->vo.startsWith("vdpau")) { QString c; @@ -1594,105 +1612,100 @@ void Core::startMplayer( QString file, double seek ) { if (pref->vdpau.ffvc1vdpau) c += "ffvc1vdpau,"; if (pref->vdpau.ffodivxvdpau) c += "ffodivxvdpau,"; if (!c.isEmpty()) { - proc->addArgument("-vc"); - proc->addArgument(c); + proc->setOption("vc", c); } } -#endif else { + #endif if (pref->coreavc) { - proc->addArgument("-vc"); - proc->addArgument("coreserve,"); + proc->setOption("vc", "coreserve,"); } + #ifndef Q_OS_WIN } -#ifndef Q_OS_WIN + #endif } -#endif if (pref->use_hwac3) { - proc->addArgument("-afm"); - proc->addArgument("hwac3"); + proc->setOption("afm", "hwac3"); } - QString lavdopts; + if (proc->isMPlayer()) { + // MPlayer + QString lavdopts; - if ( (pref->h264_skip_loop_filter == Preferences::LoopDisabled) || - ((pref->h264_skip_loop_filter == Preferences::LoopDisabledOnHD) && - (mset.is264andHD)) ) - { - if (!lavdopts.isEmpty()) lavdopts += ":"; - lavdopts += "skiploopfilter=all"; - } + if ( (pref->h264_skip_loop_filter == Preferences::LoopDisabled) || + ((pref->h264_skip_loop_filter == Preferences::LoopDisabledOnHD) && + (mset.is264andHD)) ) + { + if (!lavdopts.isEmpty()) lavdopts += ":"; + lavdopts += "skiploopfilter=all"; + } - if (pref->threads > 1) { - if (!lavdopts.isEmpty()) lavdopts += ":"; - lavdopts += "threads=" + QString::number(pref->threads); - } + if (pref->threads > 1) { + if (!lavdopts.isEmpty()) lavdopts += ":"; + lavdopts += "threads=" + QString::number(pref->threads); + } - if (!lavdopts.isEmpty()) { - proc->addArgument("-lavdopts"); - proc->addArgument(lavdopts); + if (!lavdopts.isEmpty()) { + proc->setOption("lavdopts", lavdopts); + } } + else { + // MPV + if ( (pref->h264_skip_loop_filter == Preferences::LoopDisabled) || + ((pref->h264_skip_loop_filter == Preferences::LoopDisabledOnHD) && + (mset.is264andHD)) ) + { + proc->setOption("skiploopfilter"); + } - proc->addArgument("-sub-fuzziness"); - proc->addArgument( QString::number(pref->subfuzziness) ); - - proc->addArgument("-identify"); - - if (MplayerVersion::isMplayerAtLeast(27667)) { - // From r27667 the number of chapters can be obtained from ID_CHAPTERS - mset.current_chapter_id = 0; // Reset chapters - } else { - // We need this to get info about mkv chapters - if (is_mkv) { - proc->addArgument("-msglevel"); - proc->addArgument("demux=6"); - - // **** Reset chapter *** - // Select first chapter, otherwise we cannot - // resume playback at the same point - // (time would be relative to chapter) - mset.current_chapter_id = 0; + if (pref->threads > 1) { + proc->setOption("threads", QString::number(pref->threads)); } } - proc->addArgument("-slave"); + if (!pref->hwdec.isEmpty()) proc->setOption("hwdec", pref->hwdec); - if (!pref->vo.isEmpty()) { - proc->addArgument( "-vo"); - proc->addArgument( pref->vo ); - } else { - proc->addArgument("-vo"); -#ifdef Q_OS_WIN - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) { - proc->addArgument("direct3d,"); + proc->setOption("sub-fuzziness", pref->subfuzziness); + + // From mplayer SVN r27667 the number of chapters can be obtained from ID_CHAPTERS + mset.current_chapter_id = 0; // Reset chapters + // TODO: I think the current_chapter_id thing has to be deleted + + if (pref->vo != "player_default") { + if (!pref->vo.isEmpty()) { + proc->setOption("vo", pref->vo ); } else { - proc->addArgument("directx,"); + #ifdef Q_OS_WIN + if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) { + proc->setOption("vo", "direct3d,"); + } else { + proc->setOption("vo", "directx,"); + } + #else + proc->setOption("vo", "xv,"); + #endif } -#else - proc->addArgument("xv,"); -#endif } #if USE_ADAPTER if (pref->adapter > -1) { - proc->addArgument("-adapter"); - proc->addArgument(QString::number(pref->adapter)); + proc->setOption("adapter", QString::number(pref->adapter)); } #endif - if (!pref->ao.isEmpty()) { - proc->addArgument( "-ao"); - proc->addArgument( pref->ao ); + if (pref->ao != "player_default") { + if (!pref->ao.isEmpty()) { + proc->setOption("ao", pref->ao ); + } } #if !defined(Q_OS_WIN) && !defined(Q_OS_OS2) if (pref->vo.startsWith("x11")) { - proc->addArgument( "-zoom"); + proc->setOption("zoom"); } #endif - proc->addArgument("-nokeepaspect"); // Performance options #ifdef Q_OS_WIN @@ -1715,189 +1728,124 @@ void Core::startMplayer( QString file, double seek ) { case Preferences::Idle: p = "idle"; break; default: p = "normal"; } - proc->addArgument("-priority"); - proc->addArgument( p ); + proc->setOption("priority", p); /* SetPriorityClass(GetCurrentProcess(), app_p); qDebug("Core::startMplayer: priority of smplayer process set to %d", app_p); */ #endif + if (pref->frame_drop && pref->hard_frame_drop) { + proc->setOption("framedrop", "decoder+vo"); + } + else if (pref->frame_drop) { - proc->addArgument("-framedrop"); + proc->setOption("framedrop", "vo"); } - + else if (pref->hard_frame_drop) { - proc->addArgument("-hardframedrop"); + proc->setOption("framedrop", "decoder"); } if (pref->autosync) { - proc->addArgument("-autosync"); - proc->addArgument( QString::number( pref->autosync_factor ) ); + proc->setOption("autosync", QString::number(pref->autosync_factor)); } if (pref->use_mc) { - proc->addArgument("-mc"); - proc->addArgument( QString::number( pref->mc_value ) ); - } - - if (pref->use_direct_rendering) { - proc->addArgument("-dr"); - } else { - proc->addArgument("-nodr"); + proc->setOption("mc", QString::number(pref->mc_value)); } - if (pref->use_double_buffer) { - proc->addArgument("-double"); - } else { - proc->addArgument("-nodouble"); - } - -#if !defined(Q_OS_WIN) && !defined(Q_OS_OS2) - if (!pref->use_mplayer_window) { - proc->addArgument( "-input" ); - if (MplayerVersion::isMplayerAtLeast(29058)) { - proc->addArgument( "nodefault-bindings:conf=/dev/null" ); - } else { - proc->addArgument( "conf=" + Paths::dataPath() +"/input.conf" ); - } - } -#endif + proc->setOption("dr", pref->use_direct_rendering); + proc->setOption("double", pref->use_double_buffer); #ifdef Q_WS_X11 - if (pref->disable_screensaver) { - proc->addArgument("-stop-xscreensaver"); - } else { - proc->addArgument("-nostop-xscreensaver"); - } + proc->setOption("stop-xscreensaver", pref->disable_screensaver); #endif if (!pref->use_mplayer_window) { - proc->addArgument("-wid"); + proc->disableInput(); + proc->setOption("keepaspect", false); + #if defined(Q_OS_OS2) #define WINIDFROMHWND(hwnd) ( ( hwnd ) - 0x80000000UL ) - proc->addArgument( QString::number( WINIDFROMHWND( (int) mplayerwindow->videoLayer()->winId() ) )); + proc->setOption("wid", QString::number( WINIDFROMHWND( (int) mplayerwindow->videoLayer()->winId() ) )); #else - proc->addArgument( QString::number( (qint64) mplayerwindow->videoLayer()->winId() ) ); + proc->setOption("wid", QString::number( (qint64) mplayerwindow->videoLayer()->winId() ) ); #endif #if USE_COLORKEY #if defined(Q_OS_WIN) || defined(Q_OS_OS2) if ((pref->vo.startsWith("directx")) || (pref->vo.startsWith("kva")) || (pref->vo.isEmpty())) { - proc->addArgument("-colorkey"); - //proc->addArgument( "0x"+QString::number(pref->color_key, 16) ); - proc->addArgument( ColorUtils::colorToRGB(pref->color_key) ); + proc->setOption("colorkey", ColorUtils::colorToRGB(pref->color_key)); } else { #endif + /* qDebug("Core::startMplayer: * not using -colorkey for %s", pref->vo.toUtf8().data()); qDebug("Core::startMplayer: * report if you can't see the video"); + */ #if defined(Q_OS_WIN) || defined(Q_OS_OS2) } #endif #endif // Square pixels - proc->addArgument("-monitorpixelaspect"); - proc->addArgument("1"); + proc->setOption("monitorpixelaspect", "1"); } else { // no -wid + proc->setOption("keepaspect", true); if (!pref->monitor_aspect.isEmpty()) { - proc->addArgument("-monitoraspect"); - proc->addArgument( pref->monitor_aspect ); + proc->setOption("monitoraspect", pref->monitor_aspect); } } + // OSD + proc->setOption("osd-scale", proc->isMPlayer() ? mset.subfont_osd_scale : mset.osd_scale); + // Subtitles fonts if ((pref->use_ass_subtitles) && (pref->freetype_support)) { // ASS: - proc->addArgument("-ass"); - proc->addArgument("-embeddedfonts"); + proc->setOption("ass"); + proc->setOption("embeddedfonts"); - proc->addArgument("-ass-line-spacing"); - proc->addArgument(QString::number(pref->ass_line_spacing)); + proc->setOption("ass-line-spacing", QString::number(pref->ass_line_spacing)); - proc->addArgument( "-ass-font-scale"); - proc->addArgument( QString::number(mset.sub_scale_ass) ); + proc->setOption("ass-font-scale", QString::number(mset.sub_scale_ass)); if (!pref->mplayer_is_mplayer2) { - proc->addArgument( "-noflip-hebrew" ); // It seems to be necessary to display arabic subtitles correctly when using -ass + proc->setOption("flip-hebrew",false); // It seems to be necessary to display arabic subtitles correctly when using -ass } - if (!pref->force_ass_styles) { - // Load the styles.ass file - if (!QFile::exists(Paths::subtitleStyleFile())) { - // If file doesn't exist, create it - pref->ass_styles.exportStyles(Paths::subtitleStyleFile()); - } - if (QFile::exists(Paths::subtitleStyleFile())) { - proc->addArgument("-ass-styles"); - proc->addArgument( Paths::subtitleStyleFile() ); - } else { - qWarning("Core::startMplayer: '%s' doesn't exist", Paths::subtitleStyleFile().toUtf8().constData()); - } - } else { - // Force styles for ass subtitles too - proc->addArgument("-ass-force-style"); - if (!pref->user_forced_ass_style.isEmpty()) { - proc->addArgument(pref->user_forced_ass_style); + if (pref->enable_ass_styles) { + if (!pref->force_ass_styles) { + // Load the styles.ass file + if (!QFile::exists(Paths::subtitleStyleFile())) { + // If file doesn't exist, create it + pref->ass_styles.exportStyles(Paths::subtitleStyleFile()); + } + if (QFile::exists(Paths::subtitleStyleFile())) { + proc->setOption("ass-styles", Paths::subtitleStyleFile()); + } else { + qWarning("Core::startMplayer: '%s' doesn't exist", Paths::subtitleStyleFile().toUtf8().constData()); + } } else { - proc->addArgument(pref->ass_styles.toString()); + // Force styles for ass subtitles too + if (!pref->user_forced_ass_style.isEmpty()) { + proc->setOption("ass-force-style", pref->user_forced_ass_style); + } else { + proc->setOption("ass-force-style", pref->ass_styles.toString()); + } } } + // Use the same font for OSD -#if !defined(Q_OS_OS2) - if ((pref->use_fontconfig) && (!pref->ass_styles.fontname.isEmpty())) { - #ifdef USE_FONTCONFIG_OPTIONS - if (!pref->mplayer_is_mplayer2) { // -fontconfig removed from mplayer2 - proc->addArgument("-fontconfig"); - } - #endif - proc->addArgument("-font"); - proc->addArgument( pref->ass_styles.fontname ); - } -#endif + // deleted + // Set the size of OSD - if (pref->freetype_support) { - proc->addArgument("-subfont-autoscale"); - proc->addArgument("0"); - if (!pref->mplayer_is_mplayer2) { // Prevent huge OSD in mplayer2 - proc->addArgument("-subfont-osd-scale"); - proc->addArgument(QString::number(pref->ass_styles.fontsize)); - } - proc->addArgument("-subfont-text-scale"); // Old versions (like 1.0rc2) need this - proc->addArgument(QString::number(pref->ass_styles.fontsize)); - } + // deleted } else { // NO ASS: - if (pref->freetype_support) proc->addArgument("-noass"); -#if !defined(Q_OS_OS2) - if ( (pref->use_fontconfig) && (!pref->font_name.isEmpty()) ) { - #ifdef USE_FONTCONFIG_OPTIONS - if (!pref->mplayer_is_mplayer2) { // -fontconfig removed from mplayer2 - proc->addArgument("-fontconfig"); - } - #endif - proc->addArgument("-font"); - proc->addArgument( pref->font_name ); - } -#endif - if ( (!pref->use_fontconfig) && (!pref->font_file.isEmpty()) ) { - #ifdef USE_FONTCONFIG_OPTIONS - if (!pref->mplayer_is_mplayer2) { // -nofontconfig removed from mplayer2 - proc->addArgument("-nofontconfig"); - } - #endif - proc->addArgument("-font"); - proc->addArgument( pref->font_file ); - } - - if (pref->freetype_support) { - proc->addArgument( "-subfont-autoscale"); - proc->addArgument( QString::number( pref->font_autoscale ) ); - - proc->addArgument( "-subfont-text-scale"); - proc->addArgument( QString::number(mset.sub_scale) ); - } + if (pref->freetype_support) proc->setOption("noass"); + proc->setOption("subfont-text-scale", QString::number(mset.sub_scale)); } // Subtitle encoding @@ -1915,20 +1863,16 @@ void Core::startMplayer( QString file, double seek ) { } if (!encoding.isEmpty()) { - proc->addArgument("-subcp"); - proc->addArgument( encoding ); + proc->setOption("subcp", encoding); } } if (mset.closed_caption_channel > 0) { - proc->addArgument("-subcc"); - if (MplayerVersion::isMplayerAtLeast(32607)) { - proc->addArgument( QString::number( mset.closed_caption_channel ) ); - } + proc->setOption("subcc", QString::number(mset.closed_caption_channel)); } if (pref->use_forced_subs_only) { - proc->addArgument("-forcedsubsonly"); + proc->setOption("forcedsubsonly"); } #if PROGRAM_SWITCH @@ -1936,27 +1880,26 @@ void Core::startMplayer( QString file, double seek ) { (mset.current_video_id == MediaSettings::NoneSelected) && (mset.current_audio_id == MediaSettings::NoneSelected)*/ ) { - proc->addArgument("-tsprog"); - proc->addArgument( QString::number( mset.current_program_id ) ); + proc->setOption("tsprog", QString::number(mset.current_program_id)); } // Don't set video and audio track if using -tsprog else { #endif +#if 1 if (mset.current_video_id != MediaSettings::NoneSelected) { - proc->addArgument("-vid"); - proc->addArgument( QString::number( mset.current_video_id ) ); + proc->setOption("vid", QString::number(mset.current_video_id)); } if (mset.external_audio.isEmpty()) { if (mset.current_audio_id != MediaSettings::NoneSelected) { // Workaround for MPlayer bug #1321 (http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1321) if (mdat.audios.numItems() != 1) { - proc->addArgument("-aid"); - proc->addArgument( QString::number( mset.current_audio_id ) ); + proc->setOption("aid", QString::number(mset.current_audio_id)); } } } +#endif #if PROGRAM_SWITCH } @@ -1968,7 +1911,10 @@ void Core::startMplayer( QString file, double seek ) { just_loaded_external_subs = true; // Big ugly hack :( } if (!mset.external_subtitles.isEmpty()) { - if (QFileInfo(mset.external_subtitles).suffix().toLower()=="idx") { + bool is_idx = (QFileInfo(mset.external_subtitles).suffix().toLower()=="idx"); + if (proc->isMPV()) is_idx = false; // Hack to ignore the idx extension with mpv + + if (is_idx) { // sub/idx subtitles QFileInfo fi; @@ -1981,16 +1927,16 @@ void Core::startMplayer( QString file, double seek ) { QString s = fi.path() +"/"+ fi.completeBaseName(); qDebug("Core::startMplayer: subtitle file without extension: '%s'", s.toUtf8().data()); - proc->addArgument("-vobsub"); - proc->addArgument( s ); + proc->setOption("vobsub", s); } else { - proc->addArgument("-sub"); #ifdef Q_OS_WIN if (pref->use_short_pathnames) - proc->addArgument(Helper::shortPathName(mset.external_subtitles)); + proc->setOption("sub", Helper::shortPathName(mset.external_subtitles)); else #endif - proc->addArgument( mset.external_subtitles ); + { + proc->setOption("sub", mset.external_subtitles); + } } if (mset.external_subtitles_fps != MediaSettings::SFPS_None) { QString fps; @@ -2003,54 +1949,51 @@ void Core::startMplayer( QString file, double seek ) { case MediaSettings::SFPS_29970: fps = "30000/1001"; break; default: fps = "25"; } - proc->addArgument("-subfps"); - proc->addArgument( fps ); + proc->setOption("subfps", fps); } } if (!mset.external_audio.isEmpty()) { - proc->addArgument("-audiofile"); #ifdef Q_OS_WIN if (pref->use_short_pathnames) - proc->addArgument(Helper::shortPathName(mset.external_audio)); + proc->setOption("audiofile", Helper::shortPathName(mset.external_audio)); else #endif - proc->addArgument( mset.external_audio ); + { + proc->setOption("audiofile", mset.external_audio); + } } - proc->addArgument("-subpos"); - proc->addArgument( QString::number(mset.sub_pos) ); + proc->setOption("subpos", QString::number(mset.sub_pos)); - if (mset.audio_delay!=0) { - proc->addArgument("-delay"); - proc->addArgument( QString::number( (double) mset.audio_delay/1000 ) ); + if (mset.audio_delay != 0) { + proc->setOption("delay", QString::number((double) mset.audio_delay/1000)); } - if (mset.sub_delay!=0) { - proc->addArgument("-subdelay"); - proc->addArgument( QString::number( (double) mset.sub_delay/1000 ) ); + if (mset.sub_delay != 0) { + proc->setOption("subdelay", QString::number((double) mset.sub_delay/1000)); } // Contrast, brightness... if (pref->change_video_equalizer_on_startup) { if (mset.contrast != 0) { - proc->addArgument("-contrast"); - proc->addArgument( QString::number( mset.contrast ) ); + proc->setOption("contrast", QString::number(mset.contrast)); } if (mset.brightness != 0) { - proc->addArgument("-brightness"); - proc->addArgument( QString::number( mset.brightness ) ); + proc->setOption("brightness", QString::number(mset.brightness)); } if (mset.hue != 0) { - proc->addArgument("-hue"); - proc->addArgument( QString::number( mset.hue ) ); + proc->setOption("hue", QString::number(mset.hue)); } if (mset.saturation != 0) { - proc->addArgument("-saturation"); - proc->addArgument( QString::number( mset.saturation ) ); + proc->setOption("saturation", QString::number(mset.saturation)); + } + + if (mset.gamma != 0) { + proc->setOption("gamma", QString::number(mset.gamma)); } } @@ -2062,17 +2005,15 @@ void Core::startMplayer( QString file, double seek ) { } else { if (pref->global_volume) { if (use_volume_option) { - proc->addArgument("-volume"); - proc->addArgument( QString::number( pref->volume ) ); + proc->setOption("volume", QString::number(pref->volume)); } } else { if (use_volume_option) { - proc->addArgument("-volume"); // Note: mset.volume may not be right, it can be the volume of the previous video if // playing a new one, but I think it's better to use anyway the current volume on // startup than set it to 0 or something. // The right volume will be set later, when the video starts to play. - proc->addArgument( QString::number( mset.volume ) ); + proc->setOption("volume", QString::number(mset.volume)); } } } @@ -2080,8 +2021,13 @@ void Core::startMplayer( QString file, double seek ) { if (mdat.type==TYPE_DVD) { if (!dvd_folder.isEmpty()) { - proc->addArgument("-dvd-device"); - proc->addArgument( dvd_folder ); + #ifdef Q_OS_WIN + if (pref->use_short_pathnames) { + proc->setOption("dvd-device", Helper::shortPathName(dvd_folder)); + } + else + #endif + proc->setOption("dvd-device", dvd_folder); } else { qWarning("Core::startMplayer: dvd device is empty!"); } @@ -2089,22 +2035,21 @@ void Core::startMplayer( QString file, double seek ) { if ((mdat.type==TYPE_VCD) || (mdat.type==TYPE_AUDIO_CD)) { if (!pref->cdrom_device.isEmpty()) { - proc->addArgument("-cdrom-device"); - proc->addArgument( pref->cdrom_device ); + proc->setOption("cdrom-device", pref->cdrom_device); } } + /* if (mset.current_chapter_id > 0) { - proc->addArgument("-chapter"); int chapter = mset.current_chapter_id; // Fix for older versions of mplayer: if ((mdat.type == TYPE_DVD) && (firstChapter() == 0)) chapter++; - proc->addArgument( QString::number( chapter ) ); + proc->setOption("chapter", QString::number(chapter)); } + */ if (mset.current_angle_id > 0) { - proc->addArgument("-dvdangle"); - proc->addArgument( QString::number( mset.current_angle_id ) ); + proc->setOption("dvdangle", QString::number( mset.current_angle_id)); } @@ -2126,65 +2071,43 @@ void Core::startMplayer( QString file, double seek ) { default: cache = 0; } - if (cache > 31) { // Minimum value for cache = 32 - proc->addArgument("-cache"); - proc->addArgument( QString::number( cache ) ); - } else { - proc->addArgument("-nocache"); - } + proc->setOption("cache", QString::number(cache)); if (mset.speed != 1.0) { - proc->addArgument("-speed"); - proc->addArgument( QString::number( mset.speed ) ); + proc->setOption("speed", QString::number(mset.speed)); } if (mdat.type != TYPE_TV) { // Play A - B if ((mset.A_marker > -1) && (mset.B_marker > mset.A_marker)) { - proc->addArgument("-ss"); - proc->addArgument( QString::number( mset.A_marker ) ); - proc->addArgument("-endpos"); - proc->addArgument( QString::number( mset.B_marker - mset.A_marker ) ); + proc->setOption("ss", QString::number(mset.A_marker)); + proc->setOption("endpos", QString::number(mset.B_marker - mset.A_marker)); } else // If seek < 5 it's better to allow the video to start from the beginning if ((seek >= 5) && (!mset.loop)) { - proc->addArgument("-ss"); - proc->addArgument( QString::number( seek ) ); + proc->setOption("ss", QString::number(seek)); } } // Enable the OSD later, to avoid a lot of messages to be // printed on startup - proc->addArgument("-osdlevel"); - proc->addArgument( "0" ); + proc->setOption("osdlevel", "0"); if (pref->use_idx) { - proc->addArgument("-idx"); + proc->setOption("idx"); } if (mdat.type == TYPE_STREAM) { if (pref->prefer_ipv4) { - proc->addArgument("-prefer-ipv4"); + proc->setOption("prefer-ipv4"); } else { - proc->addArgument("-prefer-ipv6"); + proc->setOption("prefer-ipv6"); } } if (pref->use_correct_pts != Preferences::Detect) { - if (pref->use_correct_pts == Preferences::Enabled) { - proc->addArgument("-correct-pts"); - } else { - if (pref->mplayer_detected_version > 0) { - if (MplayerVersion::isMplayerAtLeast(26842)) { - proc->addArgument("-nocorrect-pts"); - } else { - proc->addArgument("-no-correct-pts"); - } - } else { - qDebug("Core::startMplayer: unknown version of mplayer, not passing -no(-)correct-pts"); - } - } + proc->setOption("correct-pts", (pref->use_correct_pts == Preferences::Enabled)); } bool force_noslices = false; @@ -2199,248 +2122,214 @@ void Core::startMplayer( QString file, double seek ) { // Video filters: // Phase if (mset.phase_filter) { - proc->addArgument("-vf-add"); - proc->addArgument( "phase=A" ); + proc->addVF("phase", "A"); } // Deinterlace if (mset.current_deinterlacer != MediaSettings::NoDeinterlace) { - proc->addArgument("-vf-add"); switch (mset.current_deinterlacer) { - case MediaSettings::L5: proc->addArgument("pp=l5"); break; - case MediaSettings::Yadif: proc->addArgument("yadif"); break; - case MediaSettings::LB: proc->addArgument("pp=lb"); break; - case MediaSettings::Yadif_1: proc->addArgument("yadif=1"); break; - case MediaSettings::Kerndeint: proc->addArgument("kerndeint=5"); break; + case MediaSettings::L5: proc->addVF("pp", "l5"); break; + case MediaSettings::Yadif: proc->addVF("yadif"); break; + case MediaSettings::LB: proc->addVF("pp", "lb"); break; + case MediaSettings::Yadif_1: proc->addVF("yadif", "1"); break; + case MediaSettings::Kerndeint: proc->addVF("kerndeint", "5"); break; } } // Denoise if (mset.current_denoiser != MediaSettings::NoDenoise) { - proc->addArgument("-vf-add"); if (mset.current_denoiser==MediaSettings::DenoiseSoft) { - proc->addArgument( pref->filters->item("denoise_soft").filter() ); + proc->addVF("hqdn3d", pref->filters->item("denoise_soft").options()); } else { - proc->addArgument( pref->filters->item("denoise_normal").filter() ); + proc->addVF("hqdn3d", pref->filters->item("denoise_normal").options()); } } // Unsharp if (mset.current_unsharp != 0) { - proc->addArgument("-vf-add"); if (mset.current_unsharp == 1) { - proc->addArgument( pref->filters->item("blur").filter() ); + proc->addVF("blur", pref->filters->item("blur").options()); } else { - proc->addArgument( pref->filters->item("sharpen").filter() ); + proc->addVF("sharpen", pref->filters->item("sharpen").options()); } } // Deblock if (mset.deblock_filter) { - proc->addArgument("-vf-add"); - proc->addArgument( pref->filters->item("deblock").filter() ); + proc->addVF("deblock", pref->filters->item("deblock").options()); } // Dering if (mset.dering_filter) { - proc->addArgument("-vf-add"); - proc->addArgument( "pp=dr" ); + proc->addVF("pp", "dr"); } // Gradfun if (mset.gradfun_filter) { - proc->addArgument("-vf-add"); - proc->addArgument( pref->filters->item("gradfun").filter() ); + proc->addVF("gradfun", pref->filters->item("gradfun").options()); } // Upscale if (mset.upscaling_filter) { int width = DesktopInfo::desktop_size(mplayerwindow).width(); - proc->addArgument("-sws"); - proc->addArgument("9"); - proc->addArgument("-vf-add"); - proc->addArgument("scale="+QString::number(width)+":-2"); + proc->setOption("sws", "9"); + proc->addVF("scale", QString::number(width) + ":-2"); } // Addnoise if (mset.noise_filter) { - proc->addArgument("-vf-add"); - proc->addArgument( pref->filters->item("noise").filter() ); + proc->addVF("noise", pref->filters->item("noise").options()); } // Postprocessing if (mset.postprocessing_filter) { - proc->addArgument("-vf-add"); - proc->addArgument("pp"); - proc->addArgument("-autoq"); - proc->addArgument( QString::number(pref->autoq) ); + proc->addVF("pp"); + proc->setOption("autoq", QString::number(pref->autoq)); } // Letterbox (expand) if ((mset.add_letterbox) || (pref->fullscreen && pref->add_blackborders_on_fullscreen)) { - proc->addArgument("-vf-add"); - proc->addArgument( QString("expand=:::::%1,harddup").arg( DesktopInfo::desktop_aspectRatio(mplayerwindow)) ); - // Note: on some videos (h264 for instance) the subtitles doesn't disappear, - // appearing the new ones on top of the old ones. It seems adding another - // filter after expand fixes the problem. I chose harddup 'cos I think - // it will be harmless in mplayer. - // Anyway, if you know a proper way to fix the problem, please tell me. + proc->addVF("expand", QString("aspect=%1").arg( DesktopInfo::desktop_aspectRatio(mplayerwindow))); } // Software equalizer if ( (pref->use_soft_video_eq) ) { - proc->addArgument("-vf-add"); - QString eq_filter = "eq2,hue"; + proc->addVF("eq2"); + proc->addVF("hue"); if ( (pref->vo == "gl") || (pref->vo == "gl2") || (pref->vo == "gl_tiled") #ifdef Q_OS_WIN || (pref->vo == "directx:noaccel") #endif - ) eq_filter += ",scale"; - proc->addArgument(eq_filter); + ) + { + proc->addVF("scale"); + } } // Additional video filters, supplied by user // File if ( !mset.mplayer_additional_video_filters.isEmpty() ) { - proc->addArgument("-vf-add"); - proc->addArgument( mset.mplayer_additional_video_filters ); + proc->setOption("vf-add", mset.mplayer_additional_video_filters); } // Global if ( !pref->mplayer_additional_video_filters.isEmpty() ) { - proc->addArgument("-vf-add"); - proc->addArgument( pref->mplayer_additional_video_filters ); + proc->setOption("vf-add", pref->mplayer_additional_video_filters); } // Filters for subtitles on screenshots if ((screenshot_enabled) && (pref->subtitles_on_screenshots)) { if (pref->use_ass_subtitles) { - proc->addArgument("-vf-add"); - proc->addArgument("ass"); + proc->addVF("subs_on_screenshots", "ass"); } else { - proc->addArgument("-vf-add"); - proc->addArgument("expand=osd=1"); - //proc->addArgument("-noslices"); + proc->addVF("subs_on_screenshots"); force_noslices = true; } } // Rotate if (mset.rotate != MediaSettings::NoRotate) { - proc->addArgument( "-vf-add" ); - proc->addArgument( QString("rotate=%1").arg(mset.rotate) ); + proc->addVF("rotate", QString::number(mset.rotate)); } // Flip if (mset.flip) { - proc->addArgument( "-vf-add" ); - // expand + flip doesn't work well, a workaround is to add another - // filter between them, so that's why harddup is here - proc->addArgument("harddup,flip"); + proc->addVF("flip"); } // Mirror if (mset.mirror) { - proc->addArgument( "-vf-add" ); - proc->addArgument("mirror"); + proc->addVF("mirror"); } // Screenshots - if (screenshot_enabled) { - proc->addArgument("-vf-add"); - proc->addArgument("screenshot"); + if (screenshot_enabled) { + proc->addVF("screenshot"); } #ifndef Q_OS_WIN end_video_filters: #endif + // Template for screenshots (only works with mpv) + if ((screenshot_enabled) && (!pref->screenshot_template.isEmpty())) { + proc->setOption("screenshot_template", pref->screenshot_template); + } + // slices if ((pref->use_slices) && (!force_noslices)) { - proc->addArgument("-slices"); + proc->setOption("slices", true); } else { - proc->addArgument("-noslices"); + proc->setOption("slices", false); } // Audio channels if (mset.audio_use_channels != 0) { - proc->addArgument("-channels"); - proc->addArgument( QString::number( mset.audio_use_channels ) ); + proc->setOption("channels", QString::number(mset.audio_use_channels)); } - // Audio filters - QString af=""; - if (mset.karaoke_filter) { - af="karaoke"; - } + if (!pref->use_hwac3) { - // Stereo mode - if (mset.stereo_mode != 0) { - switch (mset.stereo_mode) { - case MediaSettings::Left: af += "channels=2:2:0:1:0:0"; break; - case MediaSettings::Right: af += "channels=2:2:1:0:1:1"; break; - case MediaSettings::Mono: af += "pan=1:0.5:0.5"; break; - case MediaSettings::Reverse: af += "channels=2:2:0:1:1:0"; break; + // Audio filters + if (mset.karaoke_filter) { + proc->addAF("karaoke"); } - } - - if (mset.extrastereo_filter) { - if (!af.isEmpty()) af += ","; - af += "extrastereo"; - } - if (mset.volnorm_filter) { - if (!af.isEmpty()) af += ","; - af += pref->filters->item("volnorm").filter(); - } + // Stereo mode + if (mset.stereo_mode != 0) { + switch (mset.stereo_mode) { + case MediaSettings::Left: proc->addAF("channels", "2:2:0:1:0:0"); break; + case MediaSettings::Right: proc->addAF("channels", "2:2:1:0:1:1"); break; + case MediaSettings::Mono: proc->addAF("pan", "1:0.5:0.5"); break; + case MediaSettings::Reverse: proc->addAF("channels", "2:2:0:1:1:0"); break; + } + } - bool use_scaletempo = (pref->use_scaletempo == Preferences::Enabled); - if (pref->use_scaletempo == Preferences::Detect) { - use_scaletempo = (MplayerVersion::isMplayerAtLeast(24924)); - } - if (use_scaletempo) { - if (!af.isEmpty()) af += ","; - af += "scaletempo"; - } + if (mset.extrastereo_filter) { + proc->addAF("extrastereo"); + } - // Audio equalizer - if (pref->use_audio_equalizer) { - if (!af.isEmpty()) af += ","; - AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : mset.audio_equalizer; - af += "equalizer=" + Helper::equalizerListToString(l); - } + if (mset.volnorm_filter) { + proc->addAF("volnorm", pref->filters->item("volnorm").options()); + } + bool use_scaletempo = (pref->use_scaletempo == Preferences::Enabled); + if (pref->use_scaletempo == Preferences::Detect) { + use_scaletempo = (MplayerVersion::isMplayerAtLeast(24924)); + } + if (use_scaletempo) { + proc->addAF("scaletempo"); + } - // Additional audio filters, supplied by user - // File - if ( !pref->mplayer_additional_audio_filters.isEmpty() ) { - if (!af.isEmpty()) af += ","; - af += pref->mplayer_additional_audio_filters; - } - // Global - if ( !mset.mplayer_additional_audio_filters.isEmpty() ) { - if (!af.isEmpty()) af += ","; - af += mset.mplayer_additional_audio_filters; - } + // Audio equalizer + if (pref->use_audio_equalizer) { + AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : mset.audio_equalizer; + proc->addAF("equalizer", Helper::equalizerListToString(l)); + } - if (!af.isEmpty()) { + // Additional audio filters, supplied by user + // File + if ( !pref->mplayer_additional_audio_filters.isEmpty() ) { + proc->setOption("af-add", pref->mplayer_additional_audio_filters); + } + // Global + if ( !mset.mplayer_additional_audio_filters.isEmpty() ) { + proc->setOption("af-add", mset.mplayer_additional_audio_filters); + } + } else { // Don't use audio filters if using the S/PDIF output - if (pref->use_hwac3) { qDebug("Core::startMplayer: audio filters are disabled when using the S/PDIF output!"); - } else { - proc->addArgument("-af"); - proc->addArgument( af ); - } } if (pref->use_soft_vol) { - proc->addArgument("-softvol"); - proc->addArgument("-softvol-max"); - proc->addArgument( QString::number(pref->softvol_max) ); + proc->setOption("softvol"); + proc->setOption("softvol-max", QString::number(pref->softvol_max)); } + proc->setOption("enable_streaming_sites_support", pref->enable_streaming_sites); + // Load edl file if (pref->use_edl_files) { QString edl_f; @@ -2457,8 +2346,7 @@ void Core::startMplayer( QString file, double seek ) { qDebug("Core::startMplayer: edl file: '%s'", edl_f.toUtf8().data()); if (!edl_f.isEmpty()) { - proc->addArgument("-edl"); - proc->addArgument(edl_f); + proc->setOption("edl", edl_f); } } @@ -2466,12 +2354,14 @@ void Core::startMplayer( QString file, double seek ) { // File if (!mset.mplayer_additional_options.isEmpty()) { QStringList args = MyProcess::splitArguments(mset.mplayer_additional_options); - QStringList::Iterator it = args.begin(); - while( it != args.end() ) { - proc->addArgument( (*it) ); - ++it; + for (int n = 0; n < args.count(); n++) { + QString arg = args[n].simplified(); + if (!arg.isEmpty()) { + proc->addUserOption(arg); + } } } + // Global if (!pref->mplayer_additional_options.isEmpty()) { QString additional_options = pref->mplayer_additional_options; @@ -2485,27 +2375,35 @@ void Core::startMplayer( QString file, double seek ) { QString arg = args[n].simplified(); if (!arg.isEmpty()) { qDebug("arg %d: %s", n, arg.toUtf8().constData()); - proc->addArgument(arg); + proc->addUserOption(arg); } } + + } + + // Last checks for the file + + // Open https URLs with ffmpeg + if (proc->isMPlayer() && file.startsWith("https")) { + file = "ffmpeg://" + file; } - // File to play - if (url_is_playlist) { - proc->addArgument("-playlist"); + if (proc->isMPV() && file.startsWith("dvdnav:")) { + // Hack to open the DVD menu with MPV + file = "dvd://menu"; } #ifdef Q_OS_WIN - if (pref->use_short_pathnames) - proc->addArgument(Helper::shortPathName(file)); - else + if (pref->use_short_pathnames) { + file = Helper::shortPathName(file); + } #endif - proc->addArgument( file ); + + proc->setMedia(file, url_is_playlist); // It seems the loop option must be after the filename if (mset.loop) { - proc->addArgument("-loop"); - proc->addArgument("0"); + proc->setOption("loop", "0"); } emit aboutToStartPlaying(); @@ -2517,13 +2415,19 @@ void Core::startMplayer( QString file, double seek ) { QString line_for_log = commandline + "\n"; emit logLineAvailable(line_for_log); -#ifdef Q_OS_WIN QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + if ((pref->use_proxy) && (pref->proxy_type == QNetworkProxy::HttpProxy) && (!pref->proxy_host.isEmpty())) { + QString proxy = QString("http://%1:%2@%3:%4").arg(pref->proxy_username).arg(pref->proxy_password).arg(pref->proxy_host).arg(pref->proxy_port); + env.insert("http_proxy", proxy); + } + //qDebug("Core::startMplayer: env: %s", env.toStringList().join(",").toUtf8().constData()); + #ifdef Q_OS_WIN if (!pref->use_windowsfontdir) { env.insert("FONTCONFIG_FILE", Paths::configPath() + "/fonts.conf"); } + #endif proc->setProcessEnvironment(env); -#endif + if ( !proc->start() ) { // error handling qWarning("Core::startMplayer: mplayer process didn't start"); @@ -2535,7 +2439,7 @@ void Core::stopMplayer() { qDebug("Core::stopMplayer"); if (!proc->isRunning()) { - qWarning("Core::stopMplayer: mplayer in not running!"); + qWarning("Core::stopMplayer: mplayer is not running!"); return; } @@ -2544,7 +2448,7 @@ void Core::stopMplayer() { connect(proc, SIGNAL(processExited()), &eventLoop, SLOT(quit())); - tellmp("quit"); + proc->quit(); QTimer::singleShot(5000, &eventLoop, SLOT(quit())); eventLoop.exec(QEventLoop::ExcludeUserInputEvents); @@ -2554,8 +2458,8 @@ void Core::stopMplayer() { proc->kill(); } #else - tellmp("quit"); - + proc->quit(); + qDebug("Core::stopMplayer: Waiting mplayer to finish..."); if (!proc->waitForFinished(pref->time_to_kill_mplayer)) { qWarning("Core::stopMplayer: process didn't finish. Killing it..."); @@ -2570,26 +2474,21 @@ void Core::stopMplayer() { void Core::goToSec( double sec ) { qDebug("Core::goToSec: %f", sec); - if (sec < 0) sec = 0; - if (sec > mdat.duration ) sec = mdat.duration - 20; - tellmp( seek_cmd(sec, 2) ); + if (sec < 0) sec = 0; + if (sec > mdat.duration ) sec = mdat.duration - 20; + seek_cmd(sec, 2); } void Core::seek(int secs) { qDebug("Core::seek: %d", secs); if ( (proc->isRunning()) && (secs!=0) ) { - tellmp( seek_cmd(secs, 0) ); + seek_cmd(secs, 0); } } -QString Core::seek_cmd(double secs, int mode) { - QString s = QString("seek %1 %2").arg(secs).arg(mode); - if (MplayerVersion::isMplayer2()) { - //hr-seek - if (pref->precise_seeking) s += " 1"; else s += " -1"; - } - return s; +void Core::seek_cmd(double secs, int mode) { + proc->seek(secs, mode, pref->precise_seeking); } void Core::sforward() { @@ -2718,7 +2617,7 @@ void Core::toggleRepeat(bool b) { // Use slave command int v = -1; // no loop if (mset.loop) v = 0; // infinite loop - tellmp( QString("loop %1 1").arg(v) ); + proc->setLoop(v); } else { // Restart mplayer if (proc->isRunning()) restartPlay(); @@ -2766,7 +2665,7 @@ void Core::toggleKaraoke(bool b) { mset.karaoke_filter = b; if (MplayerVersion::isMplayerAtLeast(31030)) { // Change filter without restarting - if (b) tellmp("af_add karaoke"); else tellmp("af_del karaoke"); + proc->enableKaraoke(b); } else { restartPlay(); } @@ -2783,7 +2682,7 @@ void Core::toggleExtrastereo(bool b) { mset.extrastereo_filter = b; if (MplayerVersion::isMplayerAtLeast(31030)) { // Change filter without restarting - if (b) tellmp("af_add extrastereo"); else tellmp("af_del extrastereo"); + proc->enableExtrastereo(b); } else { restartPlay(); } @@ -2801,7 +2700,7 @@ void Core::toggleVolnorm(bool b) { if (MplayerVersion::isMplayerAtLeast(31030)) { // Change filter without restarting QString f = pref->filters->item("volnorm").filter(); - if (b) tellmp("af_add " + f); else tellmp("af_del volnorm"); + proc->enableVolnorm(b, pref->filters->item("volnorm").options()); } else { restartPlay(); } @@ -2929,7 +2828,8 @@ void Core::setBrightness(int value) { if (value < -100) value = -100; if (value != mset.brightness) { - tellmp(pausing_prefix() + " brightness " + QString::number(value) + " 1"); + proc->setPausingPrefix(pausing_prefix()); + proc->setBrightness(value); mset.brightness = value; displayMessage( tr("Brightness: %1").arg(value) ); emit videoEqualizerNeedsUpdate(); @@ -2944,7 +2844,8 @@ void Core::setContrast(int value) { if (value < -100) value = -100; if (value != mset.contrast) { - tellmp(pausing_prefix() + " contrast " + QString::number(value) + " 1"); + proc->setPausingPrefix(pausing_prefix()); + proc->setContrast(value); mset.contrast = value; displayMessage( tr("Contrast: %1").arg(value) ); emit videoEqualizerNeedsUpdate(); @@ -2958,7 +2859,8 @@ void Core::setGamma(int value) { if (value < -100) value = -100; if (value != mset.gamma) { - tellmp(pausing_prefix() + " gamma " + QString::number(value) + " 1"); + proc->setPausingPrefix(pausing_prefix()); + proc->setGamma(value); mset.gamma= value; displayMessage( tr("Gamma: %1").arg(value) ); emit videoEqualizerNeedsUpdate(); @@ -2972,7 +2874,8 @@ void Core::setHue(int value) { if (value < -100) value = -100; if (value != mset.hue) { - tellmp(pausing_prefix() + " hue " + QString::number(value) + " 1"); + proc->setPausingPrefix(pausing_prefix()); + proc->setHue(value); mset.hue = value; displayMessage( tr("Hue: %1").arg(value) ); emit videoEqualizerNeedsUpdate(); @@ -2986,7 +2889,8 @@ void Core::setSaturation(int value) { if (value < -100) value = -100; if (value != mset.saturation) { - tellmp(pausing_prefix() + " saturation " + QString::number(value) + " 1"); + proc->setPausingPrefix(pausing_prefix()); + proc->setSaturation(value); mset.saturation = value; displayMessage( tr("Saturation: %1").arg(value) ); emit videoEqualizerNeedsUpdate(); @@ -3040,7 +2944,7 @@ void Core::setSpeed( double value ) { if (value > 100) value = 100; mset.speed = value; - tellmp( "speed_set " + QString::number( value ) ); + proc->setSpeed(value); displayMessage( tr("Speed: %1").arg(value) ); } @@ -3104,7 +3008,7 @@ void Core::setVolume(int volume, bool force) { // Change volume later, after quiting pause change_volume_after_unpause = true; } else { - tellmp("volume " + QString::number(current_volume) + " 1"); + proc->setVolume(current_volume); } if (pref->global_volume) { @@ -3131,8 +3035,8 @@ void Core::switchMute() { void Core::mute(bool b) { qDebug("Core::mute"); - int v = (b ? 1 : 0); - tellmp( pausing_prefix() + " mute " + QString::number(v) ); + proc->setPausingPrefix(pausing_prefix()); + proc->mute(b); if (pref->global_volume) { pref->mute = b; @@ -3158,7 +3062,8 @@ void Core::decVolume() { void Core::setSubDelay(int delay) { qDebug("Core::setSubDelay: %d", delay); mset.sub_delay = delay; - tellmp( pausing_prefix() + " sub_delay " + QString::number( (double) mset.sub_delay/1000 ) +" 1"); + proc->setPausingPrefix(pausing_prefix()); + proc->setSubDelay((double) mset.sub_delay/1000); displayMessage( tr("Subtitle delay: %1 ms").arg(delay) ); } @@ -3175,7 +3080,8 @@ void Core::decSubDelay() { void Core::setAudioDelay(int delay) { qDebug("Core::setAudioDelay: %d", delay); mset.audio_delay = delay; - tellmp( pausing_prefix() + " audio_delay " + QString::number( (double) mset.audio_delay/1000 ) +" 1"); + proc->setPausingPrefix(pausing_prefix()); + proc->setAudioDelay((double) mset.audio_delay/1000); displayMessage( tr("Audio delay: %1 ms").arg(delay) ); } @@ -3194,7 +3100,7 @@ void Core::incSubPos() { mset.sub_pos++; if (mset.sub_pos > 100) mset.sub_pos = 100; - tellmp("sub_pos " + QString::number( mset.sub_pos ) + " 1"); + proc->setSubPos(mset.sub_pos); } void Core::decSubPos() { @@ -3202,7 +3108,7 @@ void Core::decSubPos() { mset.sub_pos--; if (mset.sub_pos < 0) mset.sub_pos = 0; - tellmp("sub_pos " + QString::number( mset.sub_pos ) + " 1"); + proc->setSubPos(mset.sub_pos); } bool Core::subscale_need_restart() { @@ -3231,7 +3137,7 @@ void Core::changeSubScale(double value) { if (need_restart) { restartPlay(); } else { - tellmp("sub_scale " + QString::number( mset.sub_scale_ass ) + " 1"); + proc->setSubScale(mset.sub_scale_ass); } displayMessage( tr("Font scale: %1").arg(mset.sub_scale_ass) ); } @@ -3242,8 +3148,7 @@ void Core::changeSubScale(double value) { if (need_restart) { restartPlay(); } else { - tellmp("sub_scale " + QString::number( mset.sub_scale ) + " 1"); - + proc->setSubScale(mset.sub_scale); } displayMessage( tr("Font scale: %1").arg(mset.sub_scale) ); } @@ -3272,20 +3177,54 @@ void Core::decSubScale() { } } +void Core::changeOSDScale(double value) { + qDebug("Core::changeOSDScale: %f", value); + + if (value < 0) value = 0; + + if (proc->isMPlayer()) { + if (value != mset.subfont_osd_scale) { + mset.subfont_osd_scale = value; + restartPlay(); + } + } else { + if (value != mset.osd_scale) { + mset.osd_scale = value; + proc->setOSDScale(mset.osd_scale); + } + } +} + +void Core::incOSDScale() { + if (proc->isMPlayer()) { + changeOSDScale(mset.subfont_osd_scale + 1); + } else { + changeOSDScale(mset.osd_scale + 0.20); + } +} + +void Core::decOSDScale() { + if (proc->isMPlayer()) { + changeOSDScale(mset.subfont_osd_scale - 1); + } else { + changeOSDScale(mset.osd_scale - 0.20); + } +} + void Core::incSubStep() { qDebug("Core::incSubStep"); - tellmp("sub_step +1"); + proc->setSubStep(+1); } void Core::decSubStep() { qDebug("Core::decSubStep"); - tellmp("sub_step -1"); + proc->setSubStep(-1); } void Core::changeSubVisibility(bool visible) { qDebug("Core::changeSubVisilibity: %d", visible); pref->sub_visibility = visible; - tellmp(QString("sub_visibility %1").arg(pref->sub_visibility ? 1 : 0)); + proc->setSubtitlesVisibility(pref->sub_visibility); if (pref->sub_visibility) displayMessage( tr("Subtitles on") ); @@ -3310,15 +3249,13 @@ void Core::setAudioEqualizer(AudioEqualizerList values, bool restart) { } if (!restart) { - const char *command = "af_cmdline equalizer "; - if (!MplayerVersion::isMplayerAtLeast(32505)) - command = "af_eq_set_bands "; - tellmp( command + Helper::equalizerListToString(values) ); + proc->setAudioEqualizer(Helper::equalizerListToString(values)); } else { restartPlay(); } - emit audioEqualizerNeedsUpdate(); + // Infinite recursion + //emit audioEqualizerNeedsUpdate(); } void Core::updateAudioEqualizer() { @@ -3460,41 +3397,17 @@ void Core::changeSubtitle(int ID) { qDebug("Core::changeSubtitle: ID: %d", ID); - bool use_new_commands = (pref->use_new_sub_commands == Preferences::Enabled); - if (pref->use_new_sub_commands == Preferences::Detect) { - use_new_commands = (MplayerVersion::isMplayerAtLeast(25158)); - } - - if (!use_new_commands) { - // Old command sub_select - tellmp( "sub_select " + QString::number(ID) ); + int real_id = -1; + if (ID == -1) { + proc->disableSubtitles(); } else { - // New commands - int real_id = -1; - if (ID == -1) { - tellmp( "sub_source -1" ); + bool valid_item = ( (ID >= 0) && (ID < mdat.subs.numItems()) ); + if (!valid_item) qWarning("Core::changeSubtitle: ID: %d is not valid!", ID); + if ( (mdat.subs.numItems() > 0) && (valid_item) ) { + real_id = mdat.subs.itemAt(ID).ID(); + proc->setSubtitle(mdat.subs.itemAt(ID).type(), real_id); } else { - bool valid_item = ( (ID >= 0) && (ID < mdat.subs.numItems()) ); - if (!valid_item) qWarning("Core::changeSubtitle: ID: %d is not valid!", ID); - if ( (mdat.subs.numItems() > 0) && (valid_item) ) { - real_id = mdat.subs.itemAt(ID).ID(); - switch (mdat.subs.itemAt(ID).type()) { - case SubData::Vob: - tellmp( "sub_vob " + QString::number(real_id) ); - break; - case SubData::Sub: - tellmp( "sub_demux " + QString::number(real_id) ); - break; - case SubData::File: - tellmp( "sub_file " + QString::number(real_id) ); - break; - default: { - qWarning("Core::changeSubtitle: unknown type!"); - } - } - } else { - qWarning("Core::changeSubtitle: subtitle list is empty!"); - } + qWarning("Core::changeSubtitle: subtitle list is empty!"); } } @@ -3518,6 +3431,31 @@ void Core::nextSubtitle() { } } +void Core::changeSecondarySubtitle(int ID) { + // MPV only + qDebug("Core::changeSecondarySubtitle: %d", ID); + + mset.current_secondary_sub_id = ID; + if (ID == MediaSettings::SubNone) { + ID = -1; + } + if (ID == MediaSettings::NoneSelected) { + ID = -1; + } + + if (ID == -1) { + proc->disableSecondarySubtitles(); + } else { + int real_id = -1; + bool valid_item = ( (ID >= 0) && (ID < mdat.subs.numItems()) ); + if (!valid_item) qWarning("Core::changeSecondarySubtitle: ID: %d is not valid!", ID); + if ( (mdat.subs.numItems() > 0) && (valid_item) ) { + real_id = mdat.subs.itemAt(ID).ID(); + proc->setSecondarySubtitle(real_id); + } + } +} + void Core::changeAudio(int ID, bool allow_restart) { qDebug("Core::changeAudio: ID: %d, allow_restart: %d", ID, allow_restart); @@ -3536,7 +3474,7 @@ void Core::changeAudio(int ID, bool allow_restart) { if (need_restart) { restartPlay(); } else { - tellmp("switch_audio " + QString::number(ID) ); + proc->setAudio(ID); // Workaround for a mplayer problem in windows, // volume is too loud after changing audio. @@ -3593,9 +3531,9 @@ void Core::changeVideo(int ID, bool allow_restart) { } else { if (mdat.demuxer == "nsv") { // Workaround a problem with the nsv demuxer - qWarning("Core::changeVideo: not calling set_property switch_video with nsv to prevent mplayer go crazy"); + qWarning("Core::changeVideo: not changing the video with nsv to prevent mplayer go crazy"); } else { - tellmp("set_property switch_video " + QString::number(ID) ); + proc->setVideo(ID); } } } @@ -3623,10 +3561,7 @@ void Core::changeProgram(int ID) { if (ID != mset.current_program_id) { mset.current_program_id = ID; - tellmp("set_property switch_program " + QString::number(ID) ); - - tellmp("get_property switch_audio"); - tellmp("get_property switch_video"); + proc->setTSProgram(ID); /* mset.current_video_id = MediaSettings::NoneSelected; @@ -3658,7 +3593,7 @@ void Core::changeTitle(int ID) { if (mdat.type == TYPE_DVD) { #if DVDNAV_SUPPORT if (mdat.filename.startsWith("dvdnav:")) { - tellmp("switch_title " + QString::number(ID)); + proc->setTitle(ID); } else { #endif DiscData disc_data = DiscName::split(mdat.filename); @@ -3696,7 +3631,7 @@ void Core::changeChapter(int ID) { mset.current_chapter_id = ID; } else { */ - tellmp("seek_chapter " + QString::number(ID) +" 1"); + proc->setChapter(ID); mset.current_chapter_id = ID; //updateWidgets(); /* @@ -3708,7 +3643,7 @@ void Core::changeChapter(int ID) { #else if (pref->fast_chapter_change) { #endif - tellmp("seek_chapter " + QString::number(ID) +" 1"); + proc->setChapter(ID); mset.current_chapter_id = ID; updateWidgets(); } else { @@ -3729,6 +3664,22 @@ int Core::firstChapter() { return 0; } +int Core::firstDVDTitle() { + if (proc->isMPV()) { + return 0; + } else { + return 1; + } +} + +int Core::firstBlurayTitle() { + if (proc->isMPV()) { + return 0; + } else { + return 1; + } +} + void Core::prevChapter() { qDebug("Core::prevChapter"); @@ -3783,11 +3734,14 @@ void Core::changeAspectRatio( int ID ) { double asp = mset.aspectToNum( (MediaSettings::Aspect) ID); if (!pref->use_mplayer_window) { - mplayerwindow->setAspect( asp ); + mplayerwindow->setAspect(asp); } else { // Using mplayer own window if (!mdat.novideo) { - tellmp("switch_ratio " + QString::number(asp)); + if (ID == MediaSettings::AspectAuto) { + asp = mdat.video_aspect; + } + proc->setAspect(asp); } } @@ -3868,7 +3822,10 @@ void Core::changeOSD(int v) { qDebug("Core::changeOSD: %d", v); pref->osd = v; - tellmp( pausing_prefix() + " osd " + QString::number( pref->osd ) ); + + proc->setPausingPrefix(pausing_prefix()); + proc->setOSD(pref->osd); + updateWidgets(); } @@ -4010,42 +3967,20 @@ void Core::decZoom() { changeZoom( mset.zoom_factor - ZOOM_STEP ); } -#if USE_MPLAYER_PANSCAN -void Core::changePanscan(double p) { - qDebug("Core::changePanscan: %f", p); - - if (p < 0.1) p = 0; - if (p > 1) p = 1; - - mset.panscan_factor = p; - tellmp(QString("panscan %1 1").arg(mset.panscan_factor)); - displayMessage( QString("Panscan: %1").arg(mset.panscan_factor) ); -} - -void Core::incPanscan() { - changePanscan(mset.panscan_factor + .1); -} - -void Core::decPanscan() { - changePanscan(mset.panscan_factor - .1); -} -#endif - void Core::showFilenameOnOSD() { - tellmp("osd_show_property_text \"${filename}\" 5000 0"); + proc->showFilenameOnOSD(); } void Core::toggleDeinterlace() { qDebug("Core::toggleDeinterlace"); - - tellmp("step_property deinterlace"); + proc->toggleDeinterlace(); } -void Core::changeUseAss(bool b) { - qDebug("Core::changeUseAss: %d", b); +void Core::changeUseCustomSubStyle(bool b) { + qDebug("Core::changeUseCustomSubStyle: %d", b); - if (pref->use_ass_subtitles != b) { - pref->use_ass_subtitles = b; + if (pref->enable_ass_styles != b) { + pref->enable_ass_styles = b; if (proc->isRunning()) restartPlay(); } } @@ -4056,9 +3991,7 @@ void Core::toggleForcedSubsOnly(bool b) { if (pref->use_forced_subs_only != b) { pref->use_forced_subs_only = b; //if (proc->isRunning()) restartPlay(); - int v = 0; - if (b) v = 1; - tellmp( QString("forced_subs_only %1").arg(v) ); + proc->setSubForcedOnly(b); } } @@ -4090,46 +4023,44 @@ void Core::prevClosedCaptionChannel() { // dvdnav buttons void Core::dvdnavUp() { qDebug("Core::dvdnavUp"); - tellmp("dvdnav up"); + proc->discButtonPressed("up"); } void Core::dvdnavDown() { qDebug("Core::dvdnavDown"); - tellmp("dvdnav down"); + proc->discButtonPressed("down"); } void Core::dvdnavLeft() { qDebug("Core::dvdnavLeft"); - tellmp("dvdnav left"); + proc->discButtonPressed("left"); } void Core::dvdnavRight() { qDebug("Core::dvdnavRight"); - tellmp("dvdnav right"); + proc->discButtonPressed("right"); } void Core::dvdnavMenu() { qDebug("Core::dvdnavMenu"); - tellmp("dvdnav menu"); + proc->discButtonPressed("menu"); } void Core::dvdnavSelect() { qDebug("Core::dvdnavSelect"); - tellmp("dvdnav select"); + proc->discButtonPressed("select"); } void Core::dvdnavPrev() { qDebug("Core::dvdnavPrev"); - tellmp("dvdnav prev"); + proc->discButtonPressed("prev"); } void Core::dvdnavMouse() { qDebug("Core::dvdnavMouse"); if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:"))) { - //QPoint p = mplayerwindow->videoLayer()->mapFromGlobal(QCursor::pos()); - //tellmp(QString("set_mouse_pos %1 %2").arg(p.x()).arg(p.y())); - tellmp("dvdnav mouse"); + proc->discButtonPressed("mouse"); } } #endif @@ -4174,6 +4105,11 @@ void Core::displayBuffering() { emit showMessage(tr("Buffering...")); } +void Core::displayPlaying() { + qDebug("Core::displayPlaying"); + emit showMessage(tr("Starting...")); +} + void Core::gotWindowResolution(int w, int h) { qDebug("Core::gotWindowResolution: %d, %d", w, h); //double aspect = (double) w/h; @@ -4265,7 +4201,7 @@ void Core::watchState(Core::State state) { // Delayed volume change qDebug("Core::watchState: delayed volume change"); int volume = (pref->global_volume ? pref->volume : mset.volume); - tellmp("volume " + QString::number(volume) + " 1"); + proc->setVolume(volume); change_volume_after_unpause = false; } } @@ -4321,6 +4257,15 @@ void Core::initAudioTrack() { } #endif +#if NOTIFY_VIDEO_CHANGES +void Core::initVideoTrack(const Tracks & videos) { + qDebug("Core::initVideoTrack"); + mdat.videos = videos; + initializeMenus(); + updateWidgets(); +} +#endif + #if NOTIFY_AUDIO_CHANGES void Core::initAudioTrack(const Tracks & audios) { qDebug("Core::initAudioTrack"); @@ -4403,9 +4348,12 @@ void Core::initSubtitleTrack(const SubTracks & subs) { qDebug("Core::initSubtitleTrack: just_loaded_external_subs: true"); restore_subs = false; just_loaded_external_subs = false; - + QFileInfo fi(mset.external_subtitles); - if (fi.suffix().toLower() != "idx") { + bool is_idx = (fi.suffix().toLower() == "idx"); + if (proc->isMPV()) is_idx = false; // Hack to ignore the idx extension with mpv + + if (!is_idx) { // The loaded subtitle file is the last one, so // try to select that one. if (mdat.subs.numItems() > 0) { @@ -4463,6 +4411,8 @@ void Core::initSubtitleTrack(const SubTracks & subs) { } } end: + + changeSecondarySubtitle(mset.current_secondary_sub_id); updateWidgets(); } @@ -4472,6 +4422,15 @@ void Core::setSubtitleTrackAgain(const SubTracks &) { } #endif +#if NOTIFY_CHAPTER_CHANGES +void Core::updateChapterInfo(const Chapters & chapters) { + qDebug("Core::updateChapterInfo"); + mdat.chapters = chapters; + initializeMenus(); + updateWidgets(); +} +#endif + #if DVDNAV_SUPPORT void Core::dvdTitleChanged(int title) { qDebug("Core::dvdTitleChanged: %d", title); @@ -4486,8 +4445,11 @@ void Core::durationChanged(double length) { } void Core::askForInfo() { - if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:"))) { - tellmp( pausing_prefix() + " get_property length"); + if (proc->isMPlayer()) { + if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:"))) { + proc->setPausingPrefix(pausing_prefix()); + proc->askForLength(); + } } } @@ -4495,7 +4457,7 @@ void Core::dvdnavUpdateMousePos(QPoint pos) { //qDebug("Core::dvdnavUpdateMousePos"); if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:")) && (dvdnav_title_is_menu)) { if (mplayerwindow->videoLayer()->underMouse()) { - tellmp(QString("set_mouse_pos %1 %2").arg(pos.x()).arg(pos.y())); + proc->discSetMousePos(pos.x(), pos.y()); } } } |