Changeset 176 for smplayer/trunk/src/core.cpp
- Timestamp:
- May 3, 2016, 5:25:45 PM (10 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/core.cpp (modified) (157 diffs)
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 175
- Property svn:mergeinfo changed
-
smplayer/trunk/src/core.cpp
r170 r176 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 4Ricardo Villalba <[email protected]>2 Copyright (C) 2006-201 Ricardo Villalba <[email protected]> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 23 23 #include <QTextStream> 24 24 #include <QUrl> 25 25 26 26 27 #ifdef Q_OS_OS2 … … 42 43 #include "discname.h" 43 44 #include "filters.h" 45 44 46 45 47 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) … … 61 63 #ifdef YOUTUBE_SUPPORT 62 64 #include "retrieveyoutubeurl.h" 63 #ifdef YT_USE_ SCRIPT65 #ifdef YT_USE_ 64 66 #include "ytsig.h" 65 67 #endif 68 69 66 70 #endif 67 71 … … 95 99 #endif 96 100 97 proc = new MplayerProcess(this);101 ); 98 102 99 103 // Do this the first … … 138 142 */ 139 143 144 145 146 147 148 149 140 150 connect( proc, SIGNAL(receivedCacheEmptyMessage(QString)), 141 151 this, SIGNAL(buffering())); … … 185 195 connect( proc, SIGNAL(receivedStartingTime(double)), 186 196 this, SLOT(gotStartingTime(double)) ); 197 198 199 187 200 188 201 connect( proc, SIGNAL(receivedStreamTitle(QString)), … … 209 222 this, SLOT(initAudioTrack(const Tracks &)), Qt::QueuedConnection ); 210 223 #endif 224 225 226 227 228 229 230 231 232 211 233 #if DVDNAV_SUPPORT 212 234 connect( proc, SIGNAL(receivedDVDTitle(int)), … … 271 293 yt->setUseHttpsVi(pref->yt_use_https_vi); 272 294 273 connect(yt, SIGNAL(gotPreferredUrl(const QString &)), this, SLOT(openYT(const QString &))); 295 #ifdef YT_USE_SIG 296 QSettings * sigset = new QSettings(Paths::configPath() + "/sig.ini", QSettings::IniFormat, this); 297 yt->setSettings(sigset); 298 #endif 299 300 connect(yt, SIGNAL(gotPreferredUrl(const QString &, int)), this, SLOT(openYT(const QString &))); 274 301 connect(yt, SIGNAL(connecting(QString)), this, SLOT(connectingToYT(QString))); 275 302 connect(yt, SIGNAL(errorOcurred(int,QString)), this, SLOT(YTFailed(int,QString))); 276 /* connect(yt, SIGNAL(signatureNotFound()), this, SLOT(YTNoSignature())); */303 277 304 connect(yt, SIGNAL(signatureNotFound(const QString&)), this, SIGNAL(signatureNotFound(const QString&))); 278 305 connect(yt, SIGNAL(gotEmptyList()), this, SLOT(YTNoVideoUrl())); … … 288 315 #endif 289 316 290 if (proc->isRunning()) stopMplayer();291 proc->terminate();292 delete proc;317 if (proc->isRunning()) stopMplayer(); 318 proc->terminate(); 319 delete proc; 293 320 294 321 #ifndef NO_USE_INI_FILES … … 321 348 322 349 void Core::setState(State s) { 350 323 351 if (s != _state) { 324 352 _state = s; … … 366 394 367 395 if ( (mdat.type == TYPE_FILE) && (!mdat.filename.isEmpty()) ) { 368 file_settings->saveSettingsFor(mdat.filename, mset );396 file_settings->saveSettingsFor(mdat.filename, mset); 369 397 } 370 398 else 371 399 if ( (mdat.type == TYPE_TV) && (!mdat.filename.isEmpty()) ) { 372 tv_settings->saveSettingsFor(mdat.filename, mset );400 tv_settings->saveSettingsFor(mdat.filename, mset); 373 401 } 374 402 } … … 389 417 390 418 391 void Core::tellmp(const QString & command) { 392 qDebug("Core::tellmp: '%s'", command.toUtf8().data()); 393 394 //qDebug("Command: '%s'", command.toUtf8().data()); 395 if (proc->isRunning()) { 396 proc->writeToStdin( command ); 397 } else { 398 qWarning(" tellmp: no process running: %s", command.toUtf8().data()); 399 } 419 void Core::changeFullscreenMode(bool b) { 420 proc->setFullscreen(b); 400 421 } 401 422 … … 404 425 405 426 if (proc->isRunning()) { 406 QString str = QString("osd_show_text \"%1\" %2 %3\n").arg(text.toUtf8().constData()).arg(duration).arg(level); 407 if (!prefix.isEmpty()) str = prefix + " " + str; 408 qDebug("Core::displayTextOnOSD: command: '%s'", str.toUtf8().constData()); 409 proc->write(str.toLatin1()); 427 proc->setPausingPrefix(prefix); 428 proc->showOSDText(text, duration, level); 410 429 } 411 430 } … … 427 446 openDVD( DiscName::joinDVD(0, file, pref->use_dvdnav) ); 428 447 #else 429 openDVD( DiscName::joinDVD( 1, file, false) );448 openDVD( DiscName::joinDVD(, file, false) ); 430 449 #endif 431 450 } … … 446 465 qDebug("Core::open: * directory contains a dvd"); 447 466 #if DVDNAV_SUPPORT 448 openDVD( DiscName::joinDVD( 1, file, pref->use_dvdnav) );467 openDVD( DiscName::joinDVD(, file, pref->use_dvdnav) ); 449 468 #else 450 openDVD( DiscName::joinDVD( 1, file, false) );469 openDVD( DiscName::joinDVD(, file, false) ); 451 470 #endif 452 471 } else { … … 544 563 } 545 564 546 /*547 void Core::YTNoSignature() {548 emit showMessage( tr("Video protected. It can't be played."), 5000 );549 }550 */551 552 565 void Core::YTNoVideoUrl() { 553 566 emit showMessage( tr("Unable to locate the URL of the video") ); … … 580 593 581 594 QFileInfo fi(sub); 582 if ((pref->fast_load_sub) && (fi.suffix().toLower() != "idx") && (mset.external_subtitles_fps == MediaSettings::SFPS_None)) { 595 bool is_idx = (fi.suffix().toLower() == "idx"); 596 if (proc->isMPV()) is_idx = false; // Hack to ignore the idx extension with mpv 597 598 if ((pref->fast_load_sub) && (!is_idx) && (mset.external_subtitles_fps == MediaSettings::SFPS_None)) { 583 599 QString sub_file = sub; 584 600 #ifdef Q_OS_WIN … … 590 606 } 591 607 #endif 592 tellmp( "sub_load \""+ sub_file +"\"");608 ); 593 609 } else { 594 610 restartPlay(); … … 670 686 671 687 mset.current_title_id = title; 672 mset.current_chapter_id = 1;673 688 mset.current_angle_id = 1; 674 689 … … 700 715 701 716 mset.current_title_id = title; 702 mset.current_chapter_id = -1;703 717 mset.current_angle_id = -1; 704 718 … … 729 743 730 744 mset.current_title_id = title; 731 mset.current_chapter_id = -1;732 745 mset.current_angle_id = -1; 733 746 … … 777 790 778 791 mset.current_title_id = title; 779 mset.current_chapter_id = firstChapter();780 792 mset.current_angle_id = 1; 781 793 … … 826 838 827 839 mset.current_title_id = title; 828 mset.current_chapter_id = firstChapter();829 840 mset.current_angle_id = 1; 830 841 … … 878 889 879 890 // In this case we read info from config 880 tv_settings->loadSettingsFor(channel_id, mset );891 tv_settings->loadSettingsFor(channel_id, mset); 881 892 qDebug("Core::openTV: media settings read"); 882 893 } … … 893 904 894 905 #ifdef YOUTUBE_SUPPORT 895 // Check if the stream is a youtube url 896 QString yt_full_url = yt->fullUrl(name); 897 if (!yt_full_url.isEmpty()) { 898 qDebug("Core::openStream: youtube url detected: %s", yt_full_url.toLatin1().constData()); 899 name = yt_full_url; 900 yt->setPreferredQuality( (RetrieveYoutubeUrl::Quality) pref->yt_quality ); 901 qDebug("Core::openStream: user_agent: '%s'", pref->yt_user_agent.toUtf8().constData()); 902 /*if (!pref->yt_user_agent.isEmpty()) yt->setUserAgent(pref->yt_user_agent); */ 903 yt->setUserAgent(pref->yt_user_agent); 904 #ifdef YT_USE_SCRIPT 905 YTSig::setScriptFile( Paths::configPath() + "/yt.js" ); 906 #endif 907 yt->fetchPage(name); 908 return; 906 if (PREF_YT_ENABLED) { 907 // Check if the stream is a youtube url 908 QString yt_full_url = yt->fullUrl(name); 909 if (!yt_full_url.isEmpty()) { 910 qDebug("Core::openStream: youtube url detected: %s", yt_full_url.toLatin1().constData()); 911 name = yt_full_url; 912 yt->setPreferredQuality( (RetrieveYoutubeUrl::Quality) pref->yt_quality ); 913 qDebug("Core::openStream: user_agent: '%s'", pref->yt_user_agent.toUtf8().constData()); 914 /*if (!pref->yt_user_agent.isEmpty()) yt->setUserAgent(pref->yt_user_agent); */ 915 yt->setUserAgent(pref->yt_user_agent); 916 #ifdef YT_USE_YTSIG 917 YTSig::setScriptFile( Paths::configPath() + "/yt.js" ); 918 #endif 919 yt->fetchPage(name); 920 return; 921 } 909 922 } 910 923 #endif … … 959 972 // In this case we read info from config 960 973 if (!pref->dont_remember_media_settings) { 961 file_settings->loadSettingsFor(file, mset );974 file_settings->loadSettingsFor(file, mset); 962 975 qDebug("Core::playNewFile: Media settings read"); 963 976 … … 1025 1038 1026 1039 #ifdef YOUTUBE_SUPPORT 1027 // Avoid to pass to mplayer the youtube page url 1028 if (mdat.type == TYPE_STREAM) { 1029 if (mdat.filename == yt->origUrl()) { 1030 mdat.filename = yt->latestPreferredUrl(); 1040 if (PREF_YT_ENABLED) { 1041 // Avoid to pass to mplayer the youtube page url 1042 if (mdat.type == TYPE_STREAM) { 1043 if (mdat.filename == yt->origUrl()) { 1044 mdat.filename = yt->latestPreferredUrl(); 1045 } 1031 1046 } 1032 1047 } … … 1048 1063 1049 1064 initializeMenus(); // Old 1065 1066 1067 1050 1068 1051 1069 // Video … … 1097 1115 #endif 1098 1116 1099 if (mdat.n_chapters > 0) {1100 // Just to show the first chapter checked in the menu1101 mset.current_chapter_id = firstChapter();1102 }1103 1104 1117 mdat.initialized = true; 1105 1118 … … 1139 1152 } 1140 1153 1154 1155 1156 1157 1141 1158 #ifdef YOUTUBE_SUPPORT 1142 // Change the real url with the youtube page url and set the title 1143 if (mdat.type == TYPE_STREAM) { 1144 if (mdat.filename == yt->latestPreferredUrl()) { 1145 mdat.filename = yt->origUrl(); 1146 mdat.stream_title = yt->urlTitle(); 1159 if (PREF_YT_ENABLED) { 1160 // Change the real url with the youtube page url and set the title 1161 if (mdat.type == TYPE_STREAM) { 1162 if (mdat.filename == yt->latestPreferredUrl()) { 1163 mdat.filename = yt->origUrl(); 1164 mdat.stream_title = yt->urlTitle(); 1165 } 1147 1166 } 1148 1167 } … … 1201 1220 // Recover current subtitle 1202 1221 changeSubtitle( mset.current_sub_id ); 1222 1203 1223 } 1204 1224 #endif … … 1211 1231 qDebug("Core::finishRestart: don't set volume since -volume is used"); 1212 1232 } else { 1233 1234 1213 1235 if (pref->global_volume) { 1214 1236 bool was_muted = pref->mute; … … 1217 1239 } else { 1218 1240 bool was_muted = mset.mute; 1219 setVolume( mset.volume, true );1241 setVolume( mset.volume, true ); 1220 1242 if (was_muted) mute(true); 1221 1243 } 1222 } 1223 1244 */ 1245 int vol = (pref->global_volume ? pref->volume : mset.volume); 1246 volumeChanged(vol); 1247 1248 if (proc->isMPlayer() && pref->mute) { 1249 // Set mute here because mplayer doesn't have an option to set mute from the command line 1250 mute(true); 1251 } 1252 } 1253 1254 #if 0 1255 // Old. Gamma already set with option -gamma 1224 1256 if (pref->change_video_equalizer_on_startup && (mset.gamma != 0)) { 1225 1257 int gamma = mset.gamma; … … 1227 1259 setGamma( gamma ); 1228 1260 } 1261 1229 1262 // Hack to be sure that the equalizers are up to date 1230 1263 emit videoEqualizerNeedsUpdate(); … … 1244 1277 emit mediaLoaded(); 1245 1278 emit mediaInfoChanged(); 1279 1246 1280 1247 1281 updateWidgets(); // New … … 1292 1326 1293 1327 if ((proc->isRunning()) && (state()==Paused)) { 1294 tellmp("pause"); // Unpauses1328 1295 1329 } 1296 1330 else … … 1319 1353 if (proc->isRunning()) { 1320 1354 if (state() == Paused) { 1321 tellmp("frame_step"); 1322 } 1323 else { 1324 tellmp("pause"); 1355 proc->frameStep(); 1356 } else { 1357 proc->setPause(true); 1325 1358 } 1326 1359 } … … 1328 1361 1329 1362 void Core::pause() { 1330 qDebug("Core::pause");1331 1363 qDebug("Core::pause: current state: %s", stateToString().toUtf8().data()); 1332 1364 1333 1365 if (proc->isRunning()) { 1334 1366 // Pauses and unpauses 1335 tellmp("pause");1367 ); 1336 1368 } 1337 1369 } … … 1349 1381 1350 1382 if (proc->isRunning()) { 1351 tellmp("frame_step"); 1383 proc->frameStep(); 1384 } 1385 } 1386 1387 void Core::frameBackStep() { 1388 qDebug("Core::frameBackStep"); 1389 1390 if (proc->isRunning()) { 1391 proc->frameBackStep(); 1352 1392 } 1353 1393 } … … 1359 1399 (QFileInfo(pref->screenshot_directory).isDir()) ) 1360 1400 { 1361 tellmp( pausing_prefix() + " screenshot 0"); 1401 proc->setPausingPrefix(pausing_prefix()); 1402 proc->takeScreenshot(PlayerProcess::Single, pref->subtitles_on_screenshots); 1362 1403 qDebug("Core::screenshot: taken screenshot"); 1363 1404 } else { … … 1373 1414 (QFileInfo(pref->screenshot_directory).isDir()) ) 1374 1415 { 1375 tellmp( "screenshot 1");1416 ); 1376 1417 } else { 1377 1418 qDebug("Core::screenshots: error: directory for screenshots not valid"); … … 1379 1420 } 1380 1421 } 1422 1423 1424 1425 1426 1427 1428 1381 1429 1382 1430 void Core::processFinished() … … 1396 1444 qDebug("Core::processFinished: exit_code: %d", exit_code); 1397 1445 if (exit_code != 0) { 1446 1447 1398 1448 emit mplayerFinishedWithError(exit_code); 1399 1449 } … … 1433 1483 void Core::goToPos(double perc) { 1434 1484 qDebug("Core::goToPos: per: %f", perc); 1435 tellmp( seek_cmd(perc, 1));1485 ); 1436 1486 } 1437 1487 #else 1438 1488 void Core::goToPos(int perc) { 1439 1489 qDebug("Core::goToPos: per: %d", perc); 1440 tellmp( seek_cmd(perc, 1));1490 ); 1441 1491 } 1442 1492 #endif … … 1466 1516 yt->close(); 1467 1517 #endif 1468 1469 bool is_mkv = (QFileInfo(file).suffix().toLower() == "mkv");1470 1518 1471 1519 // DVD … … 1478 1526 dvd_title = disc_data.title; 1479 1527 file = disc_data.protocol + "://"; 1480 if (dvd_title > 0) file += QString::number(dvd_title);1528 if (dvd_title > ) file += QString::number(dvd_title); 1481 1529 } 1482 1530 … … 1525 1573 proc->clearArguments(); 1526 1574 1527 // Set working directory to screenshot directory 1528 if (screenshot_enabled) { 1529 qDebug("Core::startMplayer: setting working directory to '%s'", pref->screenshot_directory.toUtf8().data()); 1530 proc->setWorkingDirectory( pref->screenshot_directory ); 1531 } 1575 // Set the screenshot directory 1576 /* deleted (done later) */ 1532 1577 1533 1578 // Use absolute path, otherwise after changing to the screenshot directory … … 1536 1581 QString mplayer_bin = pref->mplayer_bin; 1537 1582 QFileInfo fi(mplayer_bin); 1538 if (fi.exists() && fi.isExecutable() && !fi.isDir()) { 1539 mplayer_bin = fi.absoluteFilePath(); 1540 } 1541 1583 if (fi.exists() && fi.isExecutable() && !fi.isDir()) { 1584 mplayer_bin = fi.absoluteFilePath(); 1585 } 1586 1587 #ifdef MPLAYER2_SUPPORT 1542 1588 if (fi.baseName().toLower() == "mplayer2") { 1543 1589 if (!pref->mplayer_is_mplayer2) { … … 1546 1592 } 1547 1593 } 1548 1549 proc->addArgument( mplayer_bin ); 1550 1551 proc-> addArgument("-noquiet");1594 #endif 1595 1596 proc->setExecutable(mplayer_bin); 1597 proc->); 1552 1598 1553 1599 #ifdef LOG_MPLAYER 1554 1600 if (pref->verbose_log) { 1555 proc-> addArgument("-v");1601 proc->"); 1556 1602 } 1557 1603 #endif 1558 1604 1559 1605 if (pref->fullscreen && pref->use_mplayer_window) { 1560 proc-> addArgument("-fs");1606 proc->); 1561 1607 } else { 1562 1608 // No mplayer fullscreen mode 1563 #if !USE_MPLAYER_PANSCAN 1564 proc->addArgument("-nofs"); 1609 proc->setOption("fs", false); 1610 } 1611 1612 #if !ALLOW_DEMUXER_CODEC_CHANGE 1613 if (pref->use_lavf_demuxer) { 1614 proc->setOption("demuxer", "lavf"); 1615 } 1565 1616 #else 1566 // The command 'panscan' requires -fs1567 proc->addArgument("-fs");1568 #endif1569 }1570 1571 proc->addArgument("-nomouseinput");1572 1573 1617 // Demuxer and audio and video codecs: 1574 1618 if (!mset.forced_demuxer.isEmpty()) { 1575 proc->addArgument("-demuxer"); 1576 proc->addArgument(mset.forced_demuxer); 1619 proc->setOption("demuxer", mset.forced_demuxer); 1577 1620 } 1578 1621 if (!mset.forced_audio_codec.isEmpty()) { 1579 proc->addArgument("-ac"); 1580 proc->addArgument(mset.forced_audio_codec); 1622 proc->setOption("ac", mset.forced_audio_codec); 1581 1623 } 1582 1624 if (!mset.forced_video_codec.isEmpty()) { 1583 proc->addArgument("-vc"); 1584 proc->addArgument(mset.forced_video_codec); 1585 } 1586 #ifndef Q_OS_WIN 1587 else { 1625 proc->setOption("vc", mset.forced_video_codec); 1626 } 1627 else 1628 #endif 1629 { 1630 #ifndef Q_OS_WIN 1588 1631 /* if (pref->vo.startsWith("x11")) { */ // My card doesn't support vdpau, I use x11 to test 1589 1632 if (pref->vo.startsWith("vdpau")) { … … 1595 1638 if (pref->vdpau.ffodivxvdpau) c += "ffodivxvdpau,"; 1596 1639 if (!c.isEmpty()) { 1597 proc->addArgument("-vc"); 1598 proc->addArgument(c); 1640 proc->setOption("vc", c); 1599 1641 } 1600 1642 } 1601 #endif1602 1643 else { 1644 1603 1645 if (pref->coreavc) { 1604 proc->addArgument("-vc"); 1605 proc->addArgument("coreserve,"); 1646 proc->setOption("vc", "coreserve,"); 1606 1647 } 1607 }1608 #ifndef Q_OS_WIN 1609 }1610 #endif 1648 1649 } 1650 1651 } 1611 1652 1612 1653 if (pref->use_hwac3) { 1613 proc->addArgument("-afm"); 1614 proc->addArgument("hwac3"); 1615 } 1616 1617 1618 QString lavdopts; 1619 1620 if ( (pref->h264_skip_loop_filter == Preferences::LoopDisabled) || 1621 ((pref->h264_skip_loop_filter == Preferences::LoopDisabledOnHD) && 1622 (mset.is264andHD)) ) 1623 { 1624 if (!lavdopts.isEmpty()) lavdopts += ":"; 1625 lavdopts += "skiploopfilter=all"; 1626 } 1627 1628 if (pref->threads > 1) { 1629 if (!lavdopts.isEmpty()) lavdopts += ":"; 1630 lavdopts += "threads=" + QString::number(pref->threads); 1631 } 1632 1633 if (!lavdopts.isEmpty()) { 1634 proc->addArgument("-lavdopts"); 1635 proc->addArgument(lavdopts); 1636 } 1637 1638 proc->addArgument("-sub-fuzziness"); 1639 proc->addArgument( QString::number(pref->subfuzziness) ); 1640 1641 proc->addArgument("-identify"); 1642 1643 if (MplayerVersion::isMplayerAtLeast(27667)) { 1644 // From r27667 the number of chapters can be obtained from ID_CHAPTERS 1645 mset.current_chapter_id = 0; // Reset chapters 1646 } else { 1647 // We need this to get info about mkv chapters 1648 if (is_mkv) { 1649 proc->addArgument("-msglevel"); 1650 proc->addArgument("demux=6"); 1651 1652 // **** Reset chapter *** 1653 // Select first chapter, otherwise we cannot 1654 // resume playback at the same point 1655 // (time would be relative to chapter) 1656 mset.current_chapter_id = 0; 1657 } 1658 } 1659 1660 proc->addArgument("-slave"); 1661 1662 if (!pref->vo.isEmpty()) { 1663 proc->addArgument( "-vo"); 1664 proc->addArgument( pref->vo ); 1665 } else { 1666 proc->addArgument("-vo"); 1667 #ifdef Q_OS_WIN 1668 if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) { 1669 proc->addArgument("direct3d,"); 1654 proc->setOption("afm", "hwac3"); 1655 } 1656 1657 1658 if (proc->isMPlayer()) { 1659 // MPlayer 1660 QString lavdopts; 1661 1662 if ( (pref->h264_skip_loop_filter == Preferences::LoopDisabled) || 1663 ((pref->h264_skip_loop_filter == Preferences::LoopDisabledOnHD) && 1664 (mset.is264andHD)) ) 1665 { 1666 if (!lavdopts.isEmpty()) lavdopts += ":"; 1667 lavdopts += "skiploopfilter=all"; 1668 } 1669 1670 if (pref->threads > 1) { 1671 if (!lavdopts.isEmpty()) lavdopts += ":"; 1672 lavdopts += "threads=" + QString::number(pref->threads); 1673 } 1674 1675 if (!lavdopts.isEmpty()) { 1676 proc->setOption("lavdopts", lavdopts); 1677 } 1678 } 1679 else { 1680 // MPV 1681 if ( (pref->h264_skip_loop_filter == Preferences::LoopDisabled) || 1682 ((pref->h264_skip_loop_filter == Preferences::LoopDisabledOnHD) && 1683 (mset.is264andHD)) ) 1684 { 1685 proc->setOption("skiploopfilter"); 1686 } 1687 1688 if (pref->threads > 1) { 1689 proc->setOption("threads", QString::number(pref->threads)); 1690 } 1691 } 1692 1693 if (!pref->hwdec.isEmpty()) proc->setOption("hwdec", pref->hwdec); 1694 1695 proc->setOption("sub-fuzziness", pref->subfuzziness); 1696 1697 if (pref->vo != "player_default") { 1698 if (!pref->vo.isEmpty()) { 1699 proc->setOption("vo", pref->vo ); 1670 1700 } else { 1671 proc->addArgument("directx,"); 1672 } 1673 #else 1674 proc->addArgument("xv,"); 1675 #endif 1701 #ifdef Q_OS_WIN 1702 if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) { 1703 proc->setOption("vo", "direct3d,"); 1704 } else { 1705 proc->setOption("vo", "directx,"); 1706 } 1707 #else 1708 proc->setOption("vo", "xv,"); 1709 #endif 1710 } 1676 1711 } 1677 1712 1678 1713 #if USE_ADAPTER 1679 1714 if (pref->adapter > -1) { 1680 proc-> addArgument("-adapter");1681 proc->addArgument(QString::number(pref->adapter));1682 } 1683 #endif 1684 1685 if (!pref->ao.isEmpty()) {1686 proc->addArgument( "-ao");1687 proc->addArgument( pref->ao );1715 proc->); 1716 1717 #endif 1718 1719 if (pref->ao != "player_default") { 1720 if (!pref->ao.isEmpty()) { 1721 ); 1722 1688 1723 } 1689 1724 1690 1725 #if !defined(Q_OS_WIN) && !defined(Q_OS_OS2) 1691 1726 if (pref->vo.startsWith("x11")) { 1692 proc->addArgument( "-zoom"); 1693 } 1694 #endif 1695 proc->addArgument("-nokeepaspect"); 1727 proc->setOption("zoom"); 1728 } 1729 #endif 1696 1730 1697 1731 // Performance options … … 1716 1750 default: p = "normal"; 1717 1751 } 1718 proc->addArgument("-priority"); 1719 proc->addArgument( p ); 1752 proc->setOption("priority", p); 1720 1753 /* 1721 1754 SetPriorityClass(GetCurrentProcess(), app_p); … … 1724 1757 #endif 1725 1758 1759 1760 1761 1762 1726 1763 if (pref->frame_drop) { 1727 proc-> addArgument("-framedrop");1728 } 1729 1764 proc->"); 1765 } 1766 else 1730 1767 if (pref->hard_frame_drop) { 1731 proc-> addArgument("-hardframedrop");1768 proc->"); 1732 1769 } 1733 1770 1734 1771 if (pref->autosync) { 1735 proc->addArgument("-autosync"); 1736 proc->addArgument( QString::number( pref->autosync_factor ) ); 1772 proc->setOption("autosync", QString::number(pref->autosync_factor)); 1737 1773 } 1738 1774 1739 1775 if (pref->use_mc) { 1740 proc->addArgument("-mc"); 1741 proc->addArgument( QString::number( pref->mc_value ) ); 1742 } 1743 1744 if (pref->use_direct_rendering) { 1745 proc->addArgument("-dr"); 1746 } else { 1747 proc->addArgument("-nodr"); 1748 } 1749 1750 if (pref->use_double_buffer) { 1751 proc->addArgument("-double"); 1752 } else { 1753 proc->addArgument("-nodouble"); 1754 } 1755 1756 #if !defined(Q_OS_WIN) && !defined(Q_OS_OS2) 1776 proc->setOption("mc", QString::number(pref->mc_value)); 1777 } 1778 1779 proc->setOption("dr", pref->use_direct_rendering); 1780 proc->setOption("double", pref->use_double_buffer); 1781 1782 #ifdef Q_WS_X11 1783 proc->setOption("stop-xscreensaver", pref->disable_screensaver); 1784 #endif 1785 1757 1786 if (!pref->use_mplayer_window) { 1758 proc->addArgument( "-input" ); 1759 if (MplayerVersion::isMplayerAtLeast(29058)) { 1760 proc->addArgument( "nodefault-bindings:conf=/dev/null" ); 1761 } else { 1762 proc->addArgument( "conf=" + Paths::dataPath() +"/input.conf" ); 1763 } 1764 } 1765 #endif 1766 1767 #ifdef Q_WS_X11 1768 if (pref->disable_screensaver) { 1769 proc->addArgument("-stop-xscreensaver"); 1770 } else { 1771 proc->addArgument("-nostop-xscreensaver"); 1772 } 1773 #endif 1774 1775 if (!pref->use_mplayer_window) { 1776 proc->addArgument("-wid"); 1787 proc->disableInput(); 1788 proc->setOption("keepaspect", false); 1789 1777 1790 #if defined(Q_OS_OS2) 1778 1791 #define WINIDFROMHWND(hwnd) ( ( hwnd ) - 0x80000000UL ) 1779 proc-> addArgument(QString::number( WINIDFROMHWND( (int) mplayerwindow->videoLayer()->winId() ) ));1792 proc-> QString::number( WINIDFROMHWND( (int) mplayerwindow->videoLayer()->winId() ) )); 1780 1793 #else 1781 proc-> addArgument(QString::number( (qint64) mplayerwindow->videoLayer()->winId() ) );1794 proc-> QString::number( (qint64) mplayerwindow->videoLayer()->winId() ) ); 1782 1795 #endif 1783 1796 … … 1785 1798 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) 1786 1799 if ((pref->vo.startsWith("directx")) || (pref->vo.startsWith("kva")) || (pref->vo.isEmpty())) { 1787 proc->addArgument("-colorkey"); 1788 //proc->addArgument( "0x"+QString::number(pref->color_key, 16) ); 1789 proc->addArgument( ColorUtils::colorToRGB(pref->color_key) ); 1800 proc->setOption("colorkey", ColorUtils::colorToRGB(pref->color_key)); 1790 1801 } else { 1791 1802 #endif 1803 1792 1804 qDebug("Core::startMplayer: * not using -colorkey for %s", pref->vo.toUtf8().data()); 1793 1805 qDebug("Core::startMplayer: * report if you can't see the video"); 1806 1794 1807 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) 1795 1808 } … … 1798 1811 1799 1812 // Square pixels 1800 proc->addArgument("-monitorpixelaspect"); 1801 proc->addArgument("1"); 1813 proc->setOption("monitorpixelaspect", "1"); 1802 1814 } else { 1803 1815 // no -wid 1816 1804 1817 if (!pref->monitor_aspect.isEmpty()) { 1805 proc->addArgument("-monitoraspect"); 1806 proc->addArgument( pref->monitor_aspect ); 1807 } 1808 } 1818 proc->setOption("monitoraspect", pref->monitor_aspect); 1819 } 1820 } 1821 1822 // OSD 1823 proc->setOption("osd-scale", proc->isMPlayer() ? pref->subfont_osd_scale : pref->osd_scale); 1809 1824 1810 1825 // Subtitles fonts 1811 1826 if ((pref->use_ass_subtitles) && (pref->freetype_support)) { 1812 1827 // ASS: 1813 proc->addArgument("-ass"); 1814 proc->addArgument("-embeddedfonts"); 1815 1816 proc->addArgument("-ass-line-spacing"); 1817 proc->addArgument(QString::number(pref->ass_line_spacing)); 1818 1819 proc->addArgument( "-ass-font-scale"); 1820 proc->addArgument( QString::number(mset.sub_scale_ass) ); 1828 proc->setOption("ass"); 1829 proc->setOption("embeddedfonts"); 1830 1831 proc->setOption("ass-line-spacing", QString::number(pref->ass_line_spacing)); 1832 1833 proc->setOption("ass-font-scale", QString::number(mset.sub_scale_ass)); 1821 1834 1822 1835 #if !defined(Q_OS_OS2) 1823 if (!pref->mplayer_is_mplayer2) { 1824 proc->addArgument( "-noflip-hebrew" ); // It seems to be necessary to display arabic subtitles correctly when using -ass 1825 } 1826 #endif 1827 1828 if (!pref->force_ass_styles) { 1829 // Load the styles.ass file 1830 if (!QFile::exists(Paths::subtitleStyleFile())) { 1831 // If file doesn't exist, create it 1832 pref->ass_styles.exportStyles(Paths::subtitleStyleFile()); 1836 #ifdef MPLAYER2_SUPPORT 1837 if (!pref->mplayer_is_mplayer2) 1838 #endif 1839 { 1840 proc->setOption("flip-hebrew",false); // It seems to be necessary to display arabic subtitles correctly when using -ass 1841 } 1842 #endif 1843 1844 if (pref->enable_ass_styles) { 1845 QString ass_force_style; 1846 if (!pref->user_forced_ass_style.isEmpty()) { 1847 ass_force_style = pref->user_forced_ass_style; 1848 } else { 1849 ass_force_style = pref->ass_styles.toString(); 1833 1850 } 1834 if (QFile::exists(Paths::subtitleStyleFile())) { 1835 proc->addArgument("-ass-styles"); 1836 proc->addArgument( Paths::subtitleStyleFile() ); 1851 1852 if (proc->isMPV()) { 1853 // MPV 1854 proc->setSubStyles(pref->ass_styles); 1855 if (pref->force_ass_styles) { 1856 proc->setOption("ass-force-style", ass_force_style); 1857 } 1837 1858 } else { 1838 qWarning("Core::startMplayer: '%s' doesn't exist", Paths::subtitleStyleFile().toUtf8().constData()); 1859 // MPlayer 1860 if (!pref->force_ass_styles) { 1861 proc->setSubStyles(pref->ass_styles, Paths::subtitleStyleFile()); 1862 } else { 1863 proc->setOption("ass-force-style", ass_force_style); 1864 } 1839 1865 } 1840 } else { 1841 // Force styles for ass subtitles too 1842 proc->addArgument("-ass-force-style"); 1843 if (!pref->user_forced_ass_style.isEmpty()) { 1844 proc->addArgument(pref->user_forced_ass_style); 1845 } else { 1846 proc->addArgument(pref->ass_styles.toString()); 1847 } 1848 } 1866 } 1867 1849 1868 // Use the same font for OSD 1850 #if !defined(Q_OS_OS2) 1851 if ((pref->use_fontconfig) && (!pref->ass_styles.fontname.isEmpty())) { 1852 #ifdef USE_FONTCONFIG_OPTIONS 1853 if (!pref->mplayer_is_mplayer2) { // -fontconfig removed from mplayer2 1854 proc->addArgument("-fontconfig"); 1855 } 1856 #endif 1857 proc->addArgument("-font"); 1858 proc->addArgument( pref->ass_styles.fontname ); 1859 } 1860 #endif 1869 // deleted 1870 1861 1871 // Set the size of OSD 1862 if (pref->freetype_support) { 1863 proc->addArgument("-subfont-autoscale"); 1864 proc->addArgument("0"); 1865 if (!pref->mplayer_is_mplayer2) { // Prevent huge OSD in mplayer2 1866 proc->addArgument("-subfont-osd-scale"); 1867 proc->addArgument(QString::number(pref->ass_styles.fontsize)); 1868 } 1869 proc->addArgument("-subfont-text-scale"); // Old versions (like 1.0rc2) need this 1870 proc->addArgument(QString::number(pref->ass_styles.fontsize)); 1871 } 1872 // deleted 1872 1873 } else { 1873 1874 // NO ASS: 1874 if (pref->freetype_support) proc->addArgument("-noass"); 1875 #if !defined(Q_OS_OS2) 1876 if ( (pref->use_fontconfig) && (!pref->font_name.isEmpty()) ) { 1877 #ifdef USE_FONTCONFIG_OPTIONS 1878 if (!pref->mplayer_is_mplayer2) { // -fontconfig removed from mplayer2 1879 proc->addArgument("-fontconfig"); 1880 } 1881 #endif 1882 proc->addArgument("-font"); 1883 proc->addArgument( pref->font_name ); 1884 } 1885 #endif 1886 if ( (!pref->use_fontconfig) && (!pref->font_file.isEmpty()) ) { 1887 #ifdef USE_FONTCONFIG_OPTIONS 1888 if (!pref->mplayer_is_mplayer2) { // -nofontconfig removed from mplayer2 1889 proc->addArgument("-nofontconfig"); 1890 } 1891 #endif 1892 proc->addArgument("-font"); 1893 proc->addArgument( pref->font_file ); 1894 } 1895 1896 if (pref->freetype_support) { 1897 proc->addArgument( "-subfont-autoscale"); 1898 proc->addArgument( QString::number( pref->font_autoscale ) ); 1899 1900 proc->addArgument( "-subfont-text-scale"); 1901 proc->addArgument( QString::number(mset.sub_scale) ); 1902 } 1875 if (pref->freetype_support) proc->setOption("noass"); 1876 proc->setOption("subfont-text-scale", QString::number(mset.sub_scale)); 1903 1877 } 1904 1878 … … 1918 1892 1919 1893 if (!encoding.isEmpty()) { 1920 proc->addArgument("-subcp"); 1921 proc->addArgument( encoding ); 1894 proc->setOption("subcp", encoding); 1922 1895 } 1923 1896 } 1924 1897 1925 1898 if (mset.closed_caption_channel > 0) { 1926 proc->addArgument("-subcc"); 1927 if (MplayerVersion::isMplayerAtLeast(32607)) { 1928 proc->addArgument( QString::number( mset.closed_caption_channel ) ); 1929 } 1899 proc->setOption("subcc", QString::number(mset.closed_caption_channel)); 1930 1900 } 1931 1901 1932 1902 if (pref->use_forced_subs_only) { 1933 proc-> addArgument("-forcedsubsonly");1903 proc->forcedsubsonly"); 1934 1904 } 1935 1905 … … 1939 1909 (mset.current_audio_id == MediaSettings::NoneSelected)*/ ) 1940 1910 { 1941 proc->addArgument("-tsprog"); 1942 proc->addArgument( QString::number( mset.current_program_id ) ); 1911 proc->setOption("tsprog", QString::number(mset.current_program_id)); 1943 1912 } 1944 1913 // Don't set video and audio track if using -tsprog … … 1946 1915 #endif 1947 1916 1917 1948 1918 if (mset.current_video_id != MediaSettings::NoneSelected) { 1949 proc->addArgument("-vid"); 1950 proc->addArgument( QString::number( mset.current_video_id ) ); 1919 proc->setOption("vid", QString::number(mset.current_video_id)); 1951 1920 } 1952 1921 … … 1955 1924 // Workaround for MPlayer bug #1321 (http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1321) 1956 1925 if (mdat.audios.numItems() != 1) { 1957 proc->addArgument("-aid"); 1958 proc->addArgument( QString::number( mset.current_audio_id ) ); 1926 proc->setOption("aid", QString::number(mset.current_audio_id)); 1959 1927 } 1960 1928 } 1961 1929 } 1930 1962 1931 1963 1932 #if PROGRAM_SWITCH … … 1971 1940 } 1972 1941 if (!mset.external_subtitles.isEmpty()) { 1973 if (QFileInfo(mset.external_subtitles).suffix().toLower()=="idx") { 1942 bool is_idx = (QFileInfo(mset.external_subtitles).suffix().toLower()=="idx"); 1943 if (proc->isMPV()) is_idx = false; // Hack to ignore the idx extension with mpv 1944 1945 if (is_idx) { 1974 1946 // sub/idx subtitles 1975 1947 QFileInfo fi; … … 1984 1956 QString s = fi.path() +"/"+ fi.completeBaseName(); 1985 1957 qDebug("Core::startMplayer: subtitle file without extension: '%s'", s.toUtf8().data()); 1986 proc->addArgument("-vobsub"); 1987 proc->addArgument( s ); 1958 proc->setOption("vobsub", s); 1988 1959 } else { 1989 proc->addArgument("-sub");1990 1960 #ifdef Q_OS_WIN 1991 1961 if (pref->use_short_pathnames) 1992 proc-> addArgument(Helper::shortPathName(mset.external_subtitles));1962 proc->Helper::shortPathName(mset.external_subtitles)); 1993 1963 else 1994 1964 #endif 1995 proc->addArgument( mset.external_subtitles ); 1965 { 1966 proc->setOption("sub", mset.external_subtitles); 1967 } 1996 1968 } 1997 1969 if (mset.external_subtitles_fps != MediaSettings::SFPS_None) { … … 2006 1978 default: fps = "25"; 2007 1979 } 2008 proc->addArgument("-subfps"); 2009 proc->addArgument( fps ); 1980 proc->setOption("subfps", fps); 2010 1981 } 2011 1982 } 2012 1983 2013 1984 if (!mset.external_audio.isEmpty()) { 2014 proc->addArgument("-audiofile");2015 1985 #ifdef Q_OS_WIN 2016 1986 if (pref->use_short_pathnames) 2017 proc-> addArgument(Helper::shortPathName(mset.external_audio));1987 proc->Helper::shortPathName(mset.external_audio)); 2018 1988 else 2019 1989 #endif 2020 proc->addArgument( mset.external_audio ); 2021 } 2022 2023 proc->addArgument("-subpos"); 2024 proc->addArgument( QString::number(mset.sub_pos) ); 2025 2026 if (mset.audio_delay!=0) { 2027 proc->addArgument("-delay"); 2028 proc->addArgument( QString::number( (double) mset.audio_delay/1000 ) ); 2029 } 2030 2031 if (mset.sub_delay!=0) { 2032 proc->addArgument("-subdelay"); 2033 proc->addArgument( QString::number( (double) mset.sub_delay/1000 ) ); 1990 { 1991 proc->setOption("audiofile", mset.external_audio); 1992 } 1993 } 1994 1995 proc->setOption("subpos", QString::number(mset.sub_pos)); 1996 1997 if (mset.audio_delay != 0) { 1998 proc->setOption("delay", QString::number((double) mset.audio_delay/1000)); 1999 } 2000 2001 if (mset.sub_delay != 0) { 2002 proc->setOption("subdelay", QString::number((double) mset.sub_delay/1000)); 2034 2003 } 2035 2004 … … 2037 2006 if (pref->change_video_equalizer_on_startup) { 2038 2007 if (mset.contrast != 0) { 2039 proc->addArgument("-contrast"); 2040 proc->addArgument( QString::number( mset.contrast ) ); 2008 proc->setOption("contrast", QString::number(mset.contrast)); 2041 2009 } 2042 2010 2043 2011 if (mset.brightness != 0) { 2044 proc->addArgument("-brightness"); 2045 proc->addArgument( QString::number( mset.brightness ) ); 2012 proc->setOption("brightness", QString::number(mset.brightness)); 2046 2013 } 2047 2014 2048 2015 if (mset.hue != 0) { 2049 proc->addArgument("-hue"); 2050 proc->addArgument( QString::number( mset.hue ) ); 2016 proc->setOption("hue", QString::number(mset.hue)); 2051 2017 } 2052 2018 2053 2019 if (mset.saturation != 0) { 2054 proc->addArgument("-saturation"); 2055 proc->addArgument( QString::number( mset.saturation ) ); 2056 } 2057 } 2058 2059 // Set volume, requires mplayer svn r27872 2060 bool use_volume_option = (MplayerVersion::isMplayerAtLeast(27872)); 2020 proc->setOption("saturation", QString::number(mset.saturation)); 2021 } 2022 2023 if (mset.gamma != 0) { 2024 proc->setOption("gamma", QString::number(mset.gamma)); 2025 } 2026 } 2027 2061 2028 2062 2029 if (pref->mplayer_additional_options.contains("-volume")) { 2063 2030 qDebug("Core::startMplayer: don't set volume since -volume is used"); 2064 2031 } else { 2065 if (pref->global_volume) { 2066 if (use_volume_option) { 2067 proc->addArgument("-volume"); 2068 proc->addArgument( QString::number( pref->volume ) ); 2069 } 2070 } else { 2071 if (use_volume_option) { 2072 proc->addArgument("-volume"); 2073 // Note: mset.volume may not be right, it can be the volume of the previous video if 2074 // playing a new one, but I think it's better to use anyway the current volume on 2075 // startup than set it to 0 or something. 2076 // The right volume will be set later, when the video starts to play. 2077 proc->addArgument( QString::number( mset.volume ) ); 2078 } 2079 } 2032 int vol = (pref->global_volume ? pref->volume : mset.volume); 2033 if (proc->isMPV()) { 2034 vol = adjustVolume(vol, pref->use_soft_vol ? pref->softvol_max : 100); 2035 } 2036 proc->setOption("volume", QString::number(vol)); 2037 } 2038 2039 if (pref->mute) { 2040 proc->setOption("mute"); 2080 2041 } 2081 2042 … … 2083 2044 if (mdat.type==TYPE_DVD) { 2084 2045 if (!dvd_folder.isEmpty()) { 2085 proc->addArgument("-dvd-device"); 2086 proc->addArgument( dvd_folder ); 2046 #ifdef Q_OS_WIN 2047 if (pref->use_short_pathnames) { 2048 proc->setOption("dvd-device", Helper::shortPathName(dvd_folder)); 2049 } 2050 else 2051 #endif 2052 proc->setOption("dvd-device", dvd_folder); 2087 2053 } else { 2088 2054 qWarning("Core::startMplayer: dvd device is empty!"); … … 2092 2058 if ((mdat.type==TYPE_VCD) || (mdat.type==TYPE_AUDIO_CD)) { 2093 2059 if (!pref->cdrom_device.isEmpty()) { 2094 proc->addArgument("-cdrom-device"); 2095 proc->addArgument( pref->cdrom_device ); 2096 } 2097 } 2098 2099 if (mset.current_chapter_id > 0) { 2100 proc->addArgument("-chapter"); 2101 int chapter = mset.current_chapter_id; 2102 // Fix for older versions of mplayer: 2103 if ((mdat.type == TYPE_DVD) && (firstChapter() == 0)) chapter++; 2104 proc->addArgument( QString::number( chapter ) ); 2060 proc->setOption("cdrom-device", pref->cdrom_device); 2061 } 2105 2062 } 2106 2063 2107 2064 if (mset.current_angle_id > 0) { 2108 proc->addArgument("-dvdangle"); 2109 proc->addArgument( QString::number( mset.current_angle_id ) ); 2065 proc->setOption("dvdangle", QString::number( mset.current_angle_id)); 2110 2066 } 2111 2067 … … 2129 2085 } 2130 2086 2131 if (cache > 31) { // Minimum value for cache = 32 2132 proc->addArgument("-cache"); 2133 proc->addArgument( QString::number( cache ) ); 2134 } else { 2135 proc->addArgument("-nocache"); 2136 } 2087 proc->setOption("cache", QString::number(cache)); 2137 2088 2138 2089 if (mset.speed != 1.0) { 2139 proc->addArgument("-speed"); 2140 proc->addArgument( QString::number( mset.speed ) ); 2090 proc->setOption("speed", QString::number(mset.speed)); 2141 2091 } 2142 2092 … … 2144 2094 // Play A - B 2145 2095 if ((mset.A_marker > -1) && (mset.B_marker > mset.A_marker)) { 2146 proc->addArgument("-ss"); 2147 proc->addArgument( QString::number( mset.A_marker ) ); 2148 proc->addArgument("-endpos"); 2149 proc->addArgument( QString::number( mset.B_marker - mset.A_marker ) ); 2096 proc->setOption("ss", QString::number(mset.A_marker)); 2097 proc->setOption("endpos", QString::number(mset.B_marker - mset.A_marker)); 2150 2098 } 2151 2099 else 2152 2100 // If seek < 5 it's better to allow the video to start from the beginning 2153 2101 if ((seek >= 5) && (!mset.loop)) { 2154 proc->addArgument("-ss"); 2155 proc->addArgument( QString::number( seek ) ); 2102 proc->setOption("ss", QString::number(seek)); 2156 2103 } 2157 2104 } … … 2159 2106 // Enable the OSD later, to avoid a lot of messages to be 2160 2107 // printed on startup 2161 proc->addArgument("-osdlevel"); 2162 proc->addArgument( "0" ); 2108 proc->setOption("osdlevel", "0"); 2163 2109 2164 2110 if (pref->use_idx) { 2165 proc-> addArgument("-idx");2111 proc->idx"); 2166 2112 } 2167 2113 2168 2114 if (mdat.type == TYPE_STREAM) { 2169 2115 if (pref->prefer_ipv4) { 2170 proc-> addArgument("-prefer-ipv4");2116 proc->prefer-ipv4"); 2171 2117 } else { 2172 proc-> addArgument("-prefer-ipv6");2118 proc->prefer-ipv6"); 2173 2119 } 2174 2120 } 2175 2121 2176 2122 if (pref->use_correct_pts != Preferences::Detect) { 2177 if (pref->use_correct_pts == Preferences::Enabled) { 2178 proc->addArgument("-correct-pts"); 2179 } else { 2180 if (pref->mplayer_detected_version > 0) { 2181 if (MplayerVersion::isMplayerAtLeast(26842)) { 2182 proc->addArgument("-nocorrect-pts"); 2183 } else { 2184 proc->addArgument("-no-correct-pts"); 2185 } 2186 } else { 2187 qDebug("Core::startMplayer: unknown version of mplayer, not passing -no(-)correct-pts"); 2188 } 2189 } 2123 proc->setOption("correct-pts", (pref->use_correct_pts == Preferences::Enabled)); 2190 2124 } 2191 2125 … … 2193 2127 2194 2128 #ifndef Q_OS_WIN 2195 if ((pref->vdpau.disable_video_filters) && (pref->vo.startsWith("vdpau"))) { 2196 qDebug("Core::startMplayer: using vdpau, video filters are ignored"); 2197 goto end_video_filters; 2129 if (proc->isMPlayer()) { 2130 if ((pref->vdpau.disable_video_filters) && (pref->vo.startsWith("vdpau"))) { 2131 qDebug("Core::startMplayer: using vdpau, video filters are ignored"); 2132 goto end_video_filters; 2133 } 2134 } else { 2135 // MPV 2136 if (!pref->hwdec.isEmpty() && pref->hwdec != "no") { 2137 qDebug("Core::startMplayer: hardware decoding is enabled. The video filters will be ignored"); 2138 goto end_video_filters; 2139 } 2198 2140 } 2199 2141 #endif … … 2202 2144 // Phase 2203 2145 if (mset.phase_filter) { 2204 proc->addArgument("-vf-add"); 2205 proc->addArgument( "phase=A" ); 2146 proc->addVF("phase", "A"); 2206 2147 } 2207 2148 2208 2149 // Deinterlace 2209 2150 if (mset.current_deinterlacer != MediaSettings::NoDeinterlace) { 2210 proc->addArgument("-vf-add");2211 2151 switch (mset.current_deinterlacer) { 2212 case MediaSettings::L5: proc->addArgument("pp=l5"); break; 2213 case MediaSettings::Yadif: proc->addArgument("yadif"); break; 2214 case MediaSettings::LB: proc->addArgument("pp=lb"); break; 2215 case MediaSettings::Yadif_1: proc->addArgument("yadif=1"); break; 2216 case MediaSettings::Kerndeint: proc->addArgument("kerndeint=5"); break; 2217 } 2152 case MediaSettings::L5: proc->addVF("l5"); break; 2153 case MediaSettings::Yadif: proc->addVF("yadif"); break; 2154 case MediaSettings::LB: proc->addVF("lb"); break; 2155 case MediaSettings::Yadif_1: proc->addVF("yadif", "1"); break; 2156 case MediaSettings::Kerndeint: proc->addVF("kerndeint", "5"); break; 2157 } 2158 } 2159 2160 // 3D stereo 2161 if (mset.stereo3d_in != "none" && !mset.stereo3d_out.isEmpty()) { 2162 proc->addStereo3DFilter(mset.stereo3d_in, mset.stereo3d_out); 2218 2163 } 2219 2164 2220 2165 // Denoise 2221 2166 if (mset.current_denoiser != MediaSettings::NoDenoise) { 2222 proc->addArgument("-vf-add");2223 2167 if (mset.current_denoiser==MediaSettings::DenoiseSoft) { 2224 proc->add Argument( pref->filters->item("denoise_soft").filter());2168 proc->add); 2225 2169 } else { 2226 proc->add Argument( pref->filters->item("denoise_normal").filter());2170 proc->add); 2227 2171 } 2228 2172 } … … 2230 2174 // Unsharp 2231 2175 if (mset.current_unsharp != 0) { 2232 proc->addArgument("-vf-add");2233 2176 if (mset.current_unsharp == 1) { 2234 proc->add Argument( pref->filters->item("blur").filter());2177 proc->add); 2235 2178 } else { 2236 proc->add Argument( pref->filters->item("sharpen").filter());2179 proc->add); 2237 2180 } 2238 2181 } … … 2240 2183 // Deblock 2241 2184 if (mset.deblock_filter) { 2242 proc->addArgument("-vf-add"); 2243 proc->addArgument( pref->filters->item("deblock").filter() ); 2185 proc->addVF("deblock", pref->filters->item("deblock").options()); 2244 2186 } 2245 2187 2246 2188 // Dering 2247 2189 if (mset.dering_filter) { 2248 proc->addArgument("-vf-add"); 2249 proc->addArgument( "pp=dr" ); 2190 proc->addVF("dering"); 2250 2191 } 2251 2192 2252 2193 // Gradfun 2253 2194 if (mset.gradfun_filter) { 2254 proc->addArgument("-vf-add"); 2255 proc->addArgument( pref->filters->item("gradfun").filter() ); 2195 proc->addVF("gradfun", pref->filters->item("gradfun").options()); 2256 2196 } 2257 2197 … … 2259 2199 if (mset.upscaling_filter) { 2260 2200 int width = DesktopInfo::desktop_size(mplayerwindow).width(); 2261 proc->addArgument("-sws"); 2262 proc->addArgument("9"); 2263 proc->addArgument("-vf-add"); 2264 proc->addArgument("scale="+QString::number(width)+":-2"); 2201 proc->setOption("sws", "9"); 2202 proc->addVF("scale", QString::number(width) + ":-2"); 2265 2203 } 2266 2204 2267 2205 // Addnoise 2268 2206 if (mset.noise_filter) { 2269 proc->addArgument("-vf-add"); 2270 proc->addArgument( pref->filters->item("noise").filter() ); 2207 proc->addVF("noise", pref->filters->item("noise").options()); 2271 2208 } 2272 2209 2273 2210 // Postprocessing 2274 2211 if (mset.postprocessing_filter) { 2275 proc->addArgument("-vf-add"); 2276 proc->addArgument("pp"); 2277 proc->addArgument("-autoq"); 2278 proc->addArgument( QString::number(pref->autoq) ); 2212 proc->addVF("postprocessing"); 2213 proc->setOption("autoq", QString::number(pref->autoq)); 2279 2214 } 2280 2215 … … 2282 2217 // Letterbox (expand) 2283 2218 if ((mset.add_letterbox) || (pref->fullscreen && pref->add_blackborders_on_fullscreen)) { 2284 proc->addArgument("-vf-add"); 2285 proc->addArgument( QString("expand=:::::%1,harddup").arg( DesktopInfo::desktop_aspectRatio(mplayerwindow)) ); 2286 // Note: on some videos (h264 for instance) the subtitles doesn't disappear, 2287 // appearing the new ones on top of the old ones. It seems adding another 2288 // filter after expand fixes the problem. I chose harddup 'cos I think 2289 // it will be harmless in mplayer. 2290 // Anyway, if you know a proper way to fix the problem, please tell me. 2219 proc->addVF("expand", QString("aspect=%1").arg( DesktopInfo::desktop_aspectRatio(mplayerwindow))); 2291 2220 } 2292 2221 2293 2222 // Software equalizer 2294 2223 if ( (pref->use_soft_video_eq) ) { 2295 proc->add Argument("-vf-add");2296 QString eq_filter = "eq2,hue";2224 proc->add"); 2225 ; 2297 2226 if ( (pref->vo == "gl") || (pref->vo == "gl2") || (pref->vo == "gl_tiled") 2298 2227 #ifdef Q_OS_WIN 2299 2228 || (pref->vo == "directx:noaccel") 2300 2229 #endif 2301 ) eq_filter += ",scale"; 2302 proc->addArgument(eq_filter); 2230 ) 2231 { 2232 proc->addVF("scale"); 2233 } 2303 2234 } 2304 2235 … … 2306 2237 // File 2307 2238 if ( !mset.mplayer_additional_video_filters.isEmpty() ) { 2308 proc->addArgument("-vf-add"); 2309 proc->addArgument( mset.mplayer_additional_video_filters ); 2239 proc->setOption("vf-add", mset.mplayer_additional_video_filters); 2310 2240 } 2311 2241 // Global 2312 2242 if ( !pref->mplayer_additional_video_filters.isEmpty() ) { 2313 proc->addArgument("-vf-add"); 2314 proc->addArgument( pref->mplayer_additional_video_filters ); 2243 proc->setOption("vf-add", pref->mplayer_additional_video_filters); 2315 2244 } 2316 2245 … … 2319 2248 { 2320 2249 if (pref->use_ass_subtitles) { 2321 proc->addArgument("-vf-add"); 2322 proc->addArgument("ass"); 2250 proc->addVF("subs_on_screenshots", "ass"); 2323 2251 } else { 2324 proc->addArgument("-vf-add"); 2325 proc->addArgument("expand=osd=1"); 2326 //proc->addArgument("-noslices"); 2252 proc->addVF("subs_on_screenshots"); 2327 2253 force_noslices = true; 2328 2254 } … … 2331 2257 // Rotate 2332 2258 if (mset.rotate != MediaSettings::NoRotate) { 2333 proc->addArgument( "-vf-add" ); 2334 proc->addArgument( QString("rotate=%1").arg(mset.rotate) ); 2259 proc->addVF("rotate", QString::number(mset.rotate)); 2335 2260 } 2336 2261 2337 2262 // Flip 2338 2263 if (mset.flip) { 2339 proc->addArgument( "-vf-add" ); 2340 // expand + flip doesn't work well, a workaround is to add another 2341 // filter between them, so that's why harddup is here 2342 proc->addArgument("harddup,flip"); 2264 proc->addVF("flip"); 2343 2265 } 2344 2266 2345 2267 // Mirror 2346 2268 if (mset.mirror) { 2347 proc->addArgument( "-vf-add" ); 2348 proc->addArgument("mirror"); 2269 proc->addVF("mirror"); 2349 2270 } 2350 2271 2351 2272 // Screenshots 2352 if (screenshot_enabled) { 2353 proc->addArgument("-vf-add"); 2354 proc->addArgument("screenshot"); 2355 } 2273 #ifdef MPLAYER_SUPPORT 2274 if (screenshot_enabled && proc->isMPlayer()) { 2275 QString dir = pref->screenshot_directory; 2276 #ifdef Q_OS_WIN 2277 if (pref->use_short_pathnames) dir = Helper::shortPathName(pref->screenshot_directory); 2278 #endif 2279 proc->enableScreenshots(dir); 2280 } 2281 #endif 2356 2282 2357 2283 #ifndef Q_OS_WIN … … 2359 2285 #endif 2360 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2361 2297 // slices 2362 2298 if ((pref->use_slices) && (!force_noslices)) { 2363 proc-> addArgument("-slices");2299 proc->); 2364 2300 } else { 2365 proc-> addArgument("-noslices");2301 proc->); 2366 2302 } 2367 2303 … … 2369 2305 // Audio channels 2370 2306 if (mset.audio_use_channels != 0) { 2371 proc->addArgument("-channels"); 2372 proc->addArgument( QString::number( mset.audio_use_channels ) ); 2373 } 2374 2375 // Audio filters 2376 QString af=""; 2377 if (mset.karaoke_filter) { 2378 af="karaoke"; 2379 } 2380 2381 // Stereo mode 2382 if (mset.stereo_mode != 0) { 2383 switch (mset.stereo_mode) { 2384 case MediaSettings::Left: af += "channels=2:2:0:1:0:0"; break; 2385 case MediaSettings::Right: af += "channels=2:2:1:0:1:1"; break; 2386 case MediaSettings::Mono: af += "pan=1:0.5:0.5"; break; 2387 case MediaSettings::Reverse: af += "channels=2:2:0:1:1:0"; break; 2388 } 2389 } 2390 2391 if (mset.extrastereo_filter) { 2392 if (!af.isEmpty()) af += ","; 2393 af += "extrastereo"; 2394 } 2395 2396 if (mset.volnorm_filter) { 2397 if (!af.isEmpty()) af += ","; 2398 af += pref->filters->item("volnorm").filter(); 2399 } 2400 2401 bool use_scaletempo = (pref->use_scaletempo == Preferences::Enabled); 2402 if (pref->use_scaletempo == Preferences::Detect) { 2403 use_scaletempo = (MplayerVersion::isMplayerAtLeast(24924)); 2404 } 2405 if (use_scaletempo) { 2406 if (!af.isEmpty()) af += ","; 2407 af += "scaletempo"; 2408 } 2409 2410 // Audio equalizer 2411 if (pref->use_audio_equalizer) { 2412 if (!af.isEmpty()) af += ","; 2413 AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : mset.audio_equalizer; 2414 af += "equalizer=" + Helper::equalizerListToString(l); 2415 } 2416 2417 2418 // Additional audio filters, supplied by user 2419 // File 2420 if ( !pref->mplayer_additional_audio_filters.isEmpty() ) { 2421 if (!af.isEmpty()) af += ","; 2422 af += pref->mplayer_additional_audio_filters; 2423 } 2424 // Global 2425 if ( !mset.mplayer_additional_audio_filters.isEmpty() ) { 2426 if (!af.isEmpty()) af += ","; 2427 af += mset.mplayer_additional_audio_filters; 2428 } 2429 2430 if (!af.isEmpty()) { 2307 proc->setOption("channels", QString::number(mset.audio_use_channels)); 2308 } 2309 2310 if (!pref->use_hwac3) { 2311 2312 // Audio filters 2313 #ifdef MPLAYER_SUPPORT 2314 if (mset.karaoke_filter) { 2315 proc->addAF("karaoke"); 2316 } 2317 #endif 2318 2319 // Stereo mode 2320 if (mset.stereo_mode != 0) { 2321 switch (mset.stereo_mode) { 2322 case MediaSettings::Left: proc->addAF("channels", "2:2:0:1:0:0"); break; 2323 case MediaSettings::Right: proc->addAF("channels", "2:2:1:0:1:1"); break; 2324 case MediaSettings::Mono: proc->addAF("pan", "1:0.5:0.5"); break; 2325 case MediaSettings::Reverse: proc->addAF("channels", "2:2:0:1:1:0"); break; 2326 } 2327 } 2328 2329 if (mset.extrastereo_filter) { 2330 proc->addAF("extrastereo"); 2331 } 2332 2333 if (mset.volnorm_filter) { 2334 proc->addAF("volnorm", pref->filters->item("volnorm").options()); 2335 } 2336 2337 bool use_scaletempo = (pref->use_scaletempo == Preferences::Enabled); 2338 if (pref->use_scaletempo == Preferences::Detect) { 2339 use_scaletempo = (MplayerVersion::isMplayerAtLeast(24924)); 2340 } 2341 if (use_scaletempo) { 2342 proc->addAF("scaletempo"); 2343 } 2344 2345 // Audio equalizer 2346 if (pref->use_audio_equalizer) { 2347 AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : mset.audio_equalizer; 2348 proc->addAF("equalizer", Helper::equalizerListToString(l)); 2349 } 2350 2351 // Additional audio filters, supplied by user 2352 // File 2353 if ( !pref->mplayer_additional_audio_filters.isEmpty() ) { 2354 proc->setOption("af-add", pref->mplayer_additional_audio_filters); 2355 } 2356 // Global 2357 if ( !mset.mplayer_additional_audio_filters.isEmpty() ) { 2358 proc->setOption("af-add", mset.mplayer_additional_audio_filters); 2359 } 2360 } else { 2431 2361 // Don't use audio filters if using the S/PDIF output 2432 if (pref->use_hwac3) {2433 2362 qDebug("Core::startMplayer: audio filters are disabled when using the S/PDIF output!"); 2434 } else {2435 proc->addArgument("-af");2436 proc->addArgument( af );2437 }2438 2363 } 2439 2364 2440 2365 if (pref->use_soft_vol) { 2441 proc->addArgument("-softvol"); 2442 proc->addArgument("-softvol-max"); 2443 proc->addArgument( QString::number(pref->softvol_max) ); 2444 } 2366 proc->setOption("softvol"); 2367 proc->setOption("softvol-max", QString::number(pref->softvol_max)); 2368 } 2369 2370 #ifdef MPV_SUPPORT 2371 if (pref->streaming_type == Preferences::StreamingAuto) { 2372 bool is_youtube = false; 2373 #ifdef YOUTUBE_SUPPORT 2374 if (PREF_YT_ENABLED) is_youtube = (file == yt->latestPreferredUrl()); 2375 #endif 2376 qDebug() << "Core::startMplayer: is_youtube:" << is_youtube; 2377 proc->setOption("enable_streaming_sites_support", !is_youtube); 2378 } else { 2379 proc->setOption("enable_streaming_sites_support", pref->streaming_type == Preferences::StreamingYTDL); 2380 } 2381 #endif 2382 2383 #ifndef Q_OS_WIN 2384 if (proc->isMPV() && file.startsWith("dvb:")) { 2385 QString channels_file = TVList::findChannelsFile(); 2386 qDebug("Core::startMplayer: channels_file: %s", channels_file.toUtf8().constData()); 2387 if (!channels_file.isEmpty()) proc->setChannelsFile(channels_file); 2388 } 2389 #endif 2390 2391 #ifdef CAPTURE_STREAM 2392 // Set the capture directory 2393 proc->setCaptureDirectory(pref->capture_directory); 2394 #endif 2445 2395 2446 2396 // Load edl file … … 2460 2410 qDebug("Core::startMplayer: edl file: '%s'", edl_f.toUtf8().data()); 2461 2411 if (!edl_f.isEmpty()) { 2462 proc->addArgument("-edl"); 2463 proc->addArgument(edl_f); 2412 proc->setOption("edl", edl_f); 2464 2413 } 2465 2414 } … … 2469 2418 if (!mset.mplayer_additional_options.isEmpty()) { 2470 2419 QStringList args = MyProcess::splitArguments(mset.mplayer_additional_options); 2471 QStringList::Iterator it = args.begin(); 2472 while( it != args.end() ) { 2473 proc->addArgument( (*it) ); 2474 ++it; 2475 } 2476 } 2420 for (int n = 0; n < args.count(); n++) { 2421 QString arg = args[n].simplified(); 2422 if (!arg.isEmpty()) { 2423 proc->addUserOption(arg); 2424 } 2425 } 2426 } 2427 2477 2428 // Global 2478 2429 if (!pref->mplayer_additional_options.isEmpty()) { 2479 2430 QString additional_options = pref->mplayer_additional_options; 2431 2480 2432 // mplayer2 doesn't support -fontconfig and -nofontconfig 2481 2433 if (pref->mplayer_is_mplayer2) { … … 2483 2435 additional_options.replace("-nofontconfig", ""); 2484 2436 } 2437 2485 2438 QStringList args = MyProcess::splitArguments(additional_options); 2486 2439 for (int n = 0; n < args.count(); n++) { … … 2488 2441 if (!arg.isEmpty()) { 2489 2442 qDebug("arg %d: %s", n, arg.toUtf8().constData()); 2490 proc->add Argument(arg);2443 proc->add(arg); 2491 2444 } 2492 2445 } 2493 } 2494 2495 // File to play 2496 if (url_is_playlist) { 2497 proc->addArgument("-playlist"); 2498 } 2446 2447 } 2448 2449 // Last checks for the file 2450 2451 // Open https URLs with ffmpeg 2452 #if 0 2453 // It doesn't seem necessary anymore 2454 if (proc->isMPlayer() && file.startsWith("https")) { 2455 file = "ffmpeg://" + file; 2456 } 2457 #endif 2458 2459 #if DVDNAV_SUPPORT 2460 if (proc->isMPV() && file.startsWith("dvdnav:")) { 2461 // Hack to open the DVD menu with MPV 2462 file = "dvd://menu"; 2463 } 2464 #endif 2499 2465 2500 2466 #ifdef Q_OS_WIN 2501 if (pref->use_short_pathnames) 2502 proc->addArgument(Helper::shortPathName(file)); 2503 else 2504 #endif 2505 proc->addArgument( file ); 2467 if (pref->use_short_pathnames) { 2468 file = Helper::shortPathName(file); 2469 } 2470 #endif 2471 2472 #ifdef MPLAYER_SUPPORT 2473 if (proc->isMPlayer()) { 2474 proc->setMedia(file, pref->use_playlist_option ? url_is_playlist : false); 2475 } else 2476 #endif 2477 { 2478 proc->setMedia(file, false); // Don't use playlist with mpv 2479 } 2506 2480 2507 2481 // It seems the loop option must be after the filename 2508 2482 if (mset.loop) { 2509 proc->addArgument("-loop"); 2510 proc->addArgument("0"); 2483 proc->setOption("loop", "0"); 2511 2484 } 2512 2485 … … 2520 2493 emit logLineAvailable(line_for_log); 2521 2494 2522 #ifdef Q_OS_WIN2523 2495 QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); 2496 2497 2498 2499 2500 2501 2524 2502 if (!pref->use_windowsfontdir) { 2525 2503 env.insert("FONTCONFIG_FILE", Paths::configPath() + "/fonts.conf"); 2526 2504 } 2505 2527 2506 proc->setProcessEnvironment(env); 2528 #endif 2507 2529 2508 if ( !proc->start() ) { 2530 2509 // error handling … … 2538 2517 2539 2518 if (!proc->isRunning()) { 2540 qWarning("Core::stopMplayer: mplayer i nnot running!");2519 qWarning("Core::stopMplayer: mplayer i not running!"); 2541 2520 return; 2542 2521 } … … 2547 2526 connect(proc, SIGNAL(processExited()), &eventLoop, SLOT(quit())); 2548 2527 2549 tellmp("quit");2528 ); 2550 2529 2551 2530 QTimer::singleShot(5000, &eventLoop, SLOT(quit())); … … 2557 2536 } 2558 2537 #else 2559 tellmp("quit");2560 2538 ); 2539 2561 2540 qDebug("Core::stopMplayer: Waiting mplayer to finish..."); 2562 2541 if (!proc->waitForFinished(pref->time_to_kill_mplayer)) { … … 2573 2552 qDebug("Core::goToSec: %f", sec); 2574 2553 2575 if (sec < 0) sec = 0;2576 if (sec > mdat.duration ) sec = mdat.duration - 20;2577 tellmp( seek_cmd(sec, 2));2554 if (sec < 0) sec = 0; 2555 if (sec > mdat.duration ) sec = mdat.duration - 20; 2556 ); 2578 2557 } 2579 2558 … … 2582 2561 qDebug("Core::seek: %d", secs); 2583 2562 if ( (proc->isRunning()) && (secs!=0) ) { 2584 tellmp( seek_cmd(secs, 0) ); 2585 } 2586 } 2587 2588 QString Core::seek_cmd(double secs, int mode) { 2589 QString s = QString("seek %1 %2").arg(secs).arg(mode); 2590 if (MplayerVersion::isMplayer2()) { 2591 //hr-seek 2592 if (pref->precise_seeking) s += " 1"; else s += " -1"; 2593 } 2594 return s; 2563 seek_cmd(secs, 0); 2564 } 2565 } 2566 2567 void Core::seek_cmd(double secs, int mode) { 2568 proc->seek(secs, mode, pref->precise_seeking); 2595 2569 } 2596 2570 … … 2638 2612 seek(-secs); 2639 2613 } 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2640 2626 2641 2627 void Core::wheelUp() { … … 2721 2707 int v = -1; // no loop 2722 2708 if (mset.loop) v = 0; // infinite loop 2723 tellmp( QString("loop %1 1").arg(v));2709 ); 2724 2710 } else { 2725 2711 // Restart mplayer … … 2730 2716 2731 2717 2732 void Core::toggleFlip() {2733 qDebug("Core::toggleFlip");2734 toggleFlip( !mset.flip );2735 }2736 2737 void Core::toggleFlip(bool b) {2738 qDebug("Core::toggleFlip: %d", b);2739 2740 if (mset.flip != b) {2741 mset.flip = b;2742 if (proc->isRunning()) restartPlay();2743 }2744 }2745 2746 void Core::toggleMirror() {2747 qDebug("Core::toggleMirror");2748 toggleMirror( !mset.mirror );2749 }2750 2751 void Core::toggleMirror(bool b) {2752 qDebug("Core::toggleMirror: %d", b);2753 2754 if (mset.mirror != b) {2755 mset.mirror = b;2756 if (proc->isRunning()) restartPlay();2757 }2758 }2759 2760 2718 // Audio filters 2719 2761 2720 void Core::toggleKaraoke() { 2762 2721 toggleKaraoke( !mset.karaoke_filter ); … … 2769 2728 if (MplayerVersion::isMplayerAtLeast(31030)) { 2770 2729 // Change filter without restarting 2771 if (b) tellmp("af_add karaoke"); else tellmp("af_del karaoke");2730 ); 2772 2731 } else { 2773 2732 restartPlay(); … … 2775 2734 } 2776 2735 } 2736 2777 2737 2778 2738 void Core::toggleExtrastereo() { … … 2786 2746 if (MplayerVersion::isMplayerAtLeast(31030)) { 2787 2747 // Change filter without restarting 2788 if (b) tellmp("af_add extrastereo"); else tellmp("af_del extrastereo");2748 ); 2789 2749 } else { 2790 2750 restartPlay(); … … 2804 2764 // Change filter without restarting 2805 2765 QString f = pref->filters->item("volnorm").filter(); 2806 if (b) tellmp("af_add " + f); else tellmp("af_del volnorm");2766 ); 2807 2767 } else { 2808 2768 restartPlay(); … … 2829 2789 2830 2790 // Video filters 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2831 2825 void Core::toggleAutophase() { 2832 2826 toggleAutophase( !mset.phase_filter ); … … 2837 2831 if ( b != mset.phase_filter) { 2838 2832 mset.phase_filter = b; 2839 restartPlay();2833 ); 2840 2834 } 2841 2835 } … … 2849 2843 if ( b != mset.deblock_filter ) { 2850 2844 mset.deblock_filter = b; 2851 restartPlay();2845 ); 2852 2846 } 2853 2847 } … … 2861 2855 if ( b != mset.dering_filter) { 2862 2856 mset.dering_filter = b; 2863 restartPlay();2857 ); 2864 2858 } 2865 2859 } … … 2873 2867 if ( b != mset.gradfun_filter) { 2874 2868 mset.gradfun_filter = b; 2875 restartPlay();2869 ); 2876 2870 } 2877 2871 } … … 2883 2877 void Core::toggleNoise(bool b) { 2884 2878 qDebug("Core::toggleNoise: %d", b); 2885 if ( b != mset.noise_filter ) {2879 if ( b!= mset.noise_filter ) { 2886 2880 mset.noise_filter = b; 2887 restartPlay();2881 ); 2888 2882 } 2889 2883 } … … 2897 2891 if ( b != mset.postprocessing_filter ) { 2898 2892 mset.postprocessing_filter = b; 2899 restartPlay();2893 ); 2900 2894 } 2901 2895 } … … 2904 2898 qDebug( "Core::changeDenoise: %d", id ); 2905 2899 if (id != mset.current_denoiser) { 2906 mset.current_denoiser = id; 2907 restartPlay(); 2900 if (proc->isMPlayer()) { 2901 mset.current_denoiser = id; 2902 restartPlay(); 2903 } else { 2904 // MPV 2905 QString dsoft = pref->filters->item("denoise_soft").options(); 2906 QString dnormal = pref->filters->item("denoise_normal").options(); 2907 // Remove previous filter 2908 switch (mset.current_denoiser) { 2909 case MediaSettings::DenoiseSoft: proc->changeVF("hqdn3d", false, dsoft); break; 2910 case MediaSettings::DenoiseNormal: proc->changeVF("hqdn3d", false, dnormal); break; 2911 } 2912 // New filter 2913 mset.current_denoiser = id; 2914 switch (mset.current_denoiser) { 2915 case MediaSettings::DenoiseSoft: proc->changeVF("hqdn3d", true, dsoft); break; 2916 case MediaSettings::DenoiseNormal: proc->changeVF("hqdn3d", true, dnormal); break; 2917 } 2918 } 2908 2919 } 2909 2920 } … … 2912 2923 qDebug( "Core::changeUnsharp: %d", id ); 2913 2924 if (id != mset.current_unsharp) { 2914 mset.current_unsharp = id; 2915 restartPlay(); 2925 if (proc->isMPlayer()) { 2926 mset.current_unsharp = id; 2927 restartPlay(); 2928 } else { 2929 // MPV 2930 // Remove previous filter 2931 switch (mset.current_unsharp) { 2932 // Current is blur 2933 case 1: proc->changeVF("blur", false); break; 2934 // Current if sharpen 2935 case 2: proc->changeVF("sharpen", false); break; 2936 } 2937 // New filter 2938 mset.current_unsharp = id; 2939 switch (mset.current_unsharp) { 2940 case 1: proc->changeVF("blur", true); break; 2941 case 2: proc->changeVF("sharpen", true); break; 2942 } 2943 } 2916 2944 } 2917 2945 } … … 2921 2949 if (mset.upscaling_filter != b) { 2922 2950 mset.upscaling_filter = b; 2923 restartPlay(); 2951 int width = DesktopInfo::desktop_size(mplayerwindow).width(); 2952 CHANGE_VF("scale", b, QString::number(width) + ":-2"); 2953 } 2954 } 2955 2956 void Core::changeStereo3d(const QString & in, const QString & out) { 2957 qDebug("Core::changeStereo3d: in: %s out: %s", in.toUtf8().constData(), out.toUtf8().constData()); 2958 2959 if ((mset.stereo3d_in != in) || (mset.stereo3d_out != out)) { 2960 if (proc->isMPlayer()) { 2961 mset.stereo3d_in = in; 2962 mset.stereo3d_out = out; 2963 restartPlay(); 2964 } else { 2965 // Remove previous filter 2966 if (mset.stereo3d_in != "none" && !mset.stereo3d_out.isEmpty()) { 2967 proc->changeStereo3DFilter(false, mset.stereo3d_in, mset.stereo3d_out); 2968 } 2969 2970 // New filter 2971 mset.stereo3d_in = in; 2972 mset.stereo3d_out = out; 2973 if (mset.stereo3d_in != "none" && !mset.stereo3d_out.isEmpty()) { 2974 proc->changeStereo3DFilter(true, mset.stereo3d_in, mset.stereo3d_out); 2975 } 2976 } 2924 2977 } 2925 2978 } … … 2932 2985 2933 2986 if (value != mset.brightness) { 2934 tellmp(pausing_prefix() + " brightness " + QString::number(value) + " 1"); 2987 proc->setPausingPrefix(pausing_prefix()); 2988 proc->setBrightness(value); 2935 2989 mset.brightness = value; 2936 2990 displayMessage( tr("Brightness: %1").arg(value) ); … … 2947 3001 2948 3002 if (value != mset.contrast) { 2949 tellmp(pausing_prefix() + " contrast " + QString::number(value) + " 1"); 3003 proc->setPausingPrefix(pausing_prefix()); 3004 proc->setContrast(value); 2950 3005 mset.contrast = value; 2951 3006 displayMessage( tr("Contrast: %1").arg(value) ); … … 2961 3016 2962 3017 if (value != mset.gamma) { 2963 tellmp(pausing_prefix() + " gamma " + QString::number(value) + " 1"); 3018 proc->setPausingPrefix(pausing_prefix()); 3019 proc->setGamma(value); 2964 3020 mset.gamma= value; 2965 3021 displayMessage( tr("Gamma: %1").arg(value) ); … … 2975 3031 2976 3032 if (value != mset.hue) { 2977 tellmp(pausing_prefix() + " hue " + QString::number(value) + " 1"); 3033 proc->setPausingPrefix(pausing_prefix()); 3034 proc->setHue(value); 2978 3035 mset.hue = value; 2979 3036 displayMessage( tr("Hue: %1").arg(value) ); … … 2989 3046 2990 3047 if (value != mset.saturation) { 2991 tellmp(pausing_prefix() + " saturation " + QString::number(value) + " 1"); 3048 proc->setPausingPrefix(pausing_prefix()); 3049 proc->setSaturation(value); 2992 3050 mset.saturation = value; 2993 3051 displayMessage( tr("Saturation: %1").arg(value) ); … … 3043 3101 3044 3102 mset.speed = value; 3045 tellmp( "speed_set " + QString::number( value ));3103 ); 3046 3104 3047 3105 displayMessage( tr("Speed: %1").arg(value) ); … … 3092 3150 } 3093 3151 3152 3153 3154 3155 3156 3157 3158 3094 3159 void Core::setVolume(int volume, bool force) { 3095 3160 qDebug("Core::setVolume: %d", volume); … … 3103 3168 if (current_volume < 0) current_volume = 0; 3104 3169 3105 if (state() == Paused) { 3106 // Change volume later, after quiting pause 3107 change_volume_after_unpause = true; 3170 if (proc->isMPV()) { 3171 // MPV 3172 int vol = adjustVolume(current_volume, pref->use_soft_vol ? pref->softvol_max : 100); 3173 proc->setVolume(vol); 3108 3174 } else { 3109 tellmp("volume " + QString::number(current_volume) + " 1"); 3175 // MPlayer 3176 if (state() == Paused) { 3177 // Change volume later, after quiting pause 3178 change_volume_after_unpause = true; 3179 } else { 3180 proc->setVolume(current_volume); 3181 } 3110 3182 } 3111 3183 … … 3134 3206 qDebug("Core::mute"); 3135 3207 3136 int v = (b ? 1 : 0);3137 tellmp( pausing_prefix() + " mute " + QString::number(v));3208 ); 3209 ); 3138 3210 3139 3211 if (pref->global_volume) { … … 3146 3218 } 3147 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3148 3232 void Core::incVolume() { 3149 3233 qDebug("Core::incVolume"); 3150 int new_vol = (pref->global_volume ? pref->volume + pref->min_step : mset.volume + pref->min_step); 3151 setVolume(new_vol); 3234 incVolume(pref->min_step); 3152 3235 } 3153 3236 3154 3237 void Core::decVolume() { 3155 3238 qDebug("Core::incVolume"); 3156 int new_vol = (pref->global_volume ? pref->volume - pref->min_step : mset.volume - pref->min_step); 3157 setVolume(new_vol); 3239 decVolume(pref->min_step); 3158 3240 } 3159 3241 … … 3161 3243 qDebug("Core::setSubDelay: %d", delay); 3162 3244 mset.sub_delay = delay; 3163 tellmp( pausing_prefix() + " sub_delay " + QString::number( (double) mset.sub_delay/1000 ) +" 1"); 3245 proc->setPausingPrefix(pausing_prefix()); 3246 proc->setSubDelay((double) mset.sub_delay/1000); 3164 3247 displayMessage( tr("Subtitle delay: %1 ms").arg(delay) ); 3165 3248 } … … 3178 3261 qDebug("Core::setAudioDelay: %d", delay); 3179 3262 mset.audio_delay = delay; 3180 tellmp( pausing_prefix() + " audio_delay " + QString::number( (double) mset.audio_delay/1000 ) +" 1"); 3263 proc->setPausingPrefix(pausing_prefix()); 3264 proc->setAudioDelay((double) mset.audio_delay/1000); 3181 3265 displayMessage( tr("Audio delay: %1 ms").arg(delay) ); 3182 3266 } … … 3197 3281 mset.sub_pos++; 3198 3282 if (mset.sub_pos > 100) mset.sub_pos = 100; 3199 tellmp("sub_pos " + QString::number( mset.sub_pos ) + " 1");3283 ); 3200 3284 } 3201 3285 … … 3205 3289 mset.sub_pos--; 3206 3290 if (mset.sub_pos < 0) mset.sub_pos = 0; 3207 tellmp("sub_pos " + QString::number( mset.sub_pos ) + " 1");3291 ); 3208 3292 } 3209 3293 … … 3234 3318 restartPlay(); 3235 3319 } else { 3236 tellmp("sub_scale " + QString::number( mset.sub_scale_ass ) + " 1");3320 ); 3237 3321 } 3238 3322 displayMessage( tr("Font scale: %1").arg(mset.sub_scale_ass) ); … … 3245 3329 restartPlay(); 3246 3330 } else { 3247 tellmp("sub_scale " + QString::number( mset.sub_scale ) + " 1"); 3248 3331 proc->setSubScale(mset.sub_scale); 3249 3332 } 3250 3333 displayMessage( tr("Font scale: %1").arg(mset.sub_scale) ); … … 3275 3358 } 3276 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3277 3394 void Core::incSubStep() { 3278 3395 qDebug("Core::incSubStep"); 3279 tellmp("sub_step +1");3396 ); 3280 3397 } 3281 3398 3282 3399 void Core::decSubStep() { 3283 3400 qDebug("Core::decSubStep"); 3284 tellmp("sub_step -1");3401 ); 3285 3402 } 3286 3403 … … 3288 3405 qDebug("Core::changeSubVisilibity: %d", visible); 3289 3406 pref->sub_visibility = visible; 3290 tellmp(QString("sub_visibility %1").arg(pref->sub_visibility ? 1 : 0));3407 ); 3291 3408 3292 3409 if (pref->sub_visibility) … … 3313 3430 3314 3431 if (!restart) { 3315 const char *command = "af_cmdline equalizer "; 3316 if (!MplayerVersion::isMplayerAtLeast(32505)) 3317 command = "af_eq_set_bands "; 3318 tellmp( command + Helper::equalizerListToString(values) ); 3432 proc->setAudioEqualizer(Helper::equalizerListToString(values)); 3319 3433 } else { 3320 3434 restartPlay(); 3321 3435 } 3322 3436 3323 emit audioEqualizerNeedsUpdate(); 3437 // Infinite recursion 3438 //emit audioEqualizerNeedsUpdate(); 3324 3439 } 3325 3440 … … 3384 3499 if (mset.starting_time != -1) { 3385 3500 mset.current_sec -= mset.starting_time; 3501 3502 3503 3504 3505 3386 3506 } 3387 3507 … … 3429 3549 } 3430 3550 3551 3552 3553 3554 3555 3556 3557 3431 3558 3432 3559 void Core::changePause() { … … 3440 3567 qDebug("Core::changeDeinterlace: %d", ID); 3441 3568 3442 if (ID!=mset.current_deinterlacer) { 3443 mset.current_deinterlacer = ID; 3444 restartPlay(); 3569 if (ID != mset.current_deinterlacer) { 3570 if (proc->isMPlayer()) { 3571 mset.current_deinterlacer = ID; 3572 restartPlay(); 3573 } else { 3574 // MPV 3575 // Remove previous filter 3576 switch (mset.current_deinterlacer) { 3577 case MediaSettings::L5: proc->changeVF("l5", false); break; 3578 case MediaSettings::Yadif: proc->changeVF("yadif", false); break; 3579 case MediaSettings::LB: proc->changeVF("lb", false); break; 3580 case MediaSettings::Yadif_1: proc->changeVF("yadif", false, "1"); break; 3581 case MediaSettings::Kerndeint: proc->changeVF("kerndeint", false, "5"); break; 3582 } 3583 mset.current_deinterlacer = ID; 3584 // New filter 3585 switch (mset.current_deinterlacer) { 3586 case MediaSettings::L5: proc->changeVF("l5", true); break; 3587 case MediaSettings::Yadif: proc->changeVF("yadif", true); break; 3588 case MediaSettings::LB: proc->changeVF("lb", true); break; 3589 case MediaSettings::Yadif_1: proc->changeVF("yadif", true, "1"); break; 3590 case MediaSettings::Kerndeint: proc->changeVF("kerndeint", true, "5"); break; 3591 } 3592 } 3445 3593 } 3446 3594 } … … 3463 3611 qDebug("Core::changeSubtitle: ID: %d", ID); 3464 3612 3465 bool use_new_commands = (pref->use_new_sub_commands == Preferences::Enabled); 3466 if (pref->use_new_sub_commands == Preferences::Detect) { 3467 use_new_commands = (MplayerVersion::isMplayerAtLeast(25158)); 3468 } 3469 3470 if (!use_new_commands) { 3471 // Old command sub_select 3472 tellmp( "sub_select " + QString::number(ID) ); 3613 int real_id = -1; 3614 if (ID == -1) { 3615 proc->disableSubtitles(); 3473 3616 } else { 3474 // New commands 3475 int real_id = -1; 3476 if (ID == -1) { 3477 tellmp( "sub_source -1" ); 3617 bool valid_item = ( (ID >= 0) && (ID < mdat.subs.numItems()) ); 3618 if (!valid_item) qWarning("Core::changeSubtitle: ID: %d is not valid!", ID); 3619 if ( (mdat.subs.numItems() > 0) && (valid_item) ) { 3620 real_id = mdat.subs.itemAt(ID).ID(); 3621 proc->setSubtitle(mdat.subs.itemAt(ID).type(), real_id); 3478 3622 } else { 3479 bool valid_item = ( (ID >= 0) && (ID < mdat.subs.numItems()) ); 3480 if (!valid_item) qWarning("Core::changeSubtitle: ID: %d is not valid!", ID); 3481 if ( (mdat.subs.numItems() > 0) && (valid_item) ) { 3482 real_id = mdat.subs.itemAt(ID).ID(); 3483 switch (mdat.subs.itemAt(ID).type()) { 3484 case SubData::Vob: 3485 tellmp( "sub_vob " + QString::number(real_id) ); 3486 break; 3487 case SubData::Sub: 3488 tellmp( "sub_demux " + QString::number(real_id) ); 3489 break; 3490 case SubData::File: 3491 tellmp( "sub_file " + QString::number(real_id) ); 3492 break; 3493 default: { 3494 qWarning("Core::changeSubtitle: unknown type!"); 3495 } 3496 } 3497 } else { 3498 qWarning("Core::changeSubtitle: subtitle list is empty!"); 3499 } 3623 qWarning("Core::changeSubtitle: subtitle list is empty!"); 3500 3624 } 3501 3625 } … … 3521 3645 } 3522 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3523 3674 void Core::changeAudio(int ID, bool allow_restart) { 3524 3675 qDebug("Core::changeAudio: ID: %d, allow_restart: %d", ID, allow_restart); … … 3529 3680 3530 3681 bool need_restart = false; 3682 3531 3683 if (allow_restart) { 3532 3684 need_restart = (pref->fast_audio_change == Preferences::Disabled); … … 3535 3687 } 3536 3688 } 3689 3537 3690 3538 3691 if (need_restart) { 3539 restartPlay(); 3692 restartPlay(); 3540 3693 } else { 3541 tellmp("switch_audio " + QString::number(ID));3694 ); 3542 3695 // Workaround for a mplayer problem in windows, 3543 3696 // volume is too loud after changing audio. … … 3546 3699 // the volume is reduced if using -softvol-max. 3547 3700 3548 if (pref->mplayer_additional_options.contains("-volume")) { 3549 qDebug("Core::changeAudio: don't set volume since -volume is used"); 3550 } else { 3551 if (pref->global_volume) { 3552 setVolume( pref->volume, true); 3553 if (pref->mute) mute(true); 3701 if (proc->isMPlayer()) { 3702 if (pref->mplayer_additional_options.contains("-volume")) { 3703 qDebug("Core::changeAudio: don't set volume since -volume is used"); 3554 3704 } else { 3555 setVolume( mset.volume, true ); 3556 if (mset.mute) mute(true); // if muted, mute again 3705 if (pref->global_volume) { 3706 setVolume( pref->volume, true); 3707 if (pref->mute) mute(true); 3708 } else { 3709 setVolume( mset.volume, true ); 3710 if (mset.mute) mute(true); // if muted, mute again 3711 } 3557 3712 } 3558 3713 } … … 3596 3751 if (mdat.demuxer == "nsv") { 3597 3752 // Workaround a problem with the nsv demuxer 3598 qWarning("Core::changeVideo: not c alling set_property switch_video with nsv to prevent mplayer go crazy");3753 qWarning("Core::changeVideo: not cvideo with nsv to prevent mplayer go crazy"); 3599 3754 } else { 3600 tellmp("set_property switch_video " + QString::number(ID));3755 ); 3601 3756 } 3602 3757 } … … 3626 3781 if (ID != mset.current_program_id) { 3627 3782 mset.current_program_id = ID; 3628 tellmp("set_property switch_program " + QString::number(ID) ); 3629 3630 tellmp("get_property switch_audio"); 3631 tellmp("get_property switch_video"); 3783 proc->setTSProgram(ID); 3632 3784 3633 3785 /* … … 3661 3813 #if DVDNAV_SUPPORT 3662 3814 if (mdat.filename.startsWith("dvdnav:")) { 3663 tellmp("switch_title " + QString::number(ID));3815 ); 3664 3816 } else { 3665 3817 #endif … … 3689 3841 void Core::changeChapter(int ID) { 3690 3842 qDebug("Core::changeChapter: ID: %d", ID); 3691 3692 if (mdat.type != TYPE_DVD) { 3693 /* 3694 if (mdat.chapters.find(ID) > -1) { 3695 double start = mdat.chapters.item(ID).start(); 3696 qDebug("Core::changeChapter: start: %f", start); 3697 goToSec(start); 3698 mset.current_chapter_id = ID; 3699 } else { 3700 */ 3701 tellmp("seek_chapter " + QString::number(ID) +" 1"); 3702 mset.current_chapter_id = ID; 3703 //updateWidgets(); 3704 /* 3705 } 3706 */ 3707 } else { 3708 #if SMART_DVD_CHAPTERS 3709 if (pref->cache_for_dvds == 0) { 3710 #else 3711 if (pref->fast_chapter_change) { 3712 #endif 3713 tellmp("seek_chapter " + QString::number(ID) +" 1"); 3714 mset.current_chapter_id = ID; 3715 updateWidgets(); 3716 } else { 3717 stopMplayer(); 3718 mset.current_chapter_id = ID; 3719 //goToPos(0); 3720 mset.current_sec = 0; 3721 restartPlay(); 3722 } 3723 } 3843 proc->setChapter(ID); 3724 3844 } 3725 3845 … … 3732 3852 } 3733 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3734 3870 void Core::prevChapter() { 3735 3871 qDebug("Core::prevChapter"); 3736 3737 int last_chapter = 0; 3738 int first_chapter = firstChapter(); 3739 3740 int ID = mdat.chapters.itemBeforeTime(mset.current_sec).ID(); 3741 3742 if (ID == -1) { 3743 last_chapter = mdat.n_chapters + firstChapter() - 1; 3744 3745 ID = mset.current_chapter_id - 1; 3746 if (ID < first_chapter) { 3747 ID = last_chapter; 3748 } 3749 } 3750 3751 changeChapter(ID); 3872 proc->previousChapter(); 3752 3873 } 3753 3874 3754 3875 void Core::nextChapter() { 3755 3876 qDebug("Core::nextChapter"); 3756 3757 int last_chapter = mdat.n_chapters + firstChapter() - 1; 3758 3759 int ID = mdat.chapters.itemAfterTime(mset.current_sec).ID(); 3760 3761 if (ID == -1) { 3762 ID = mset.current_chapter_id + 1; 3763 if (ID > last_chapter) { 3764 ID = firstChapter(); 3765 } 3766 } 3767 3768 changeChapter(ID); 3877 proc->nextChapter(); 3769 3878 } 3770 3879 … … 3786 3895 3787 3896 if (!pref->use_mplayer_window) { 3788 mplayerwindow->setAspect( asp);3897 mplayerwindow->setAspect(); 3789 3898 } else { 3790 3899 // Using mplayer own window 3791 3900 if (!mdat.novideo) { 3792 tellmp("switch_ratio " + QString::number(asp)); 3901 if (ID == MediaSettings::AspectAuto) { 3902 asp = mdat.video_aspect; 3903 } 3904 proc->setAspect(asp); 3793 3905 } 3794 3906 } … … 3863 3975 if (mset.add_letterbox != b) { 3864 3976 mset.add_letterbox = b; 3865 restartPlay(); 3866 } 3977 CHANGE_VF("letterbox", b, DesktopInfo::desktop_aspectRatio(mplayerwindow)); 3978 } 3979 } 3980 3981 void Core::changeLetterboxOnFullscreen(bool b) { 3982 qDebug("Core::changeLetterboxOnFullscreen: %d", b); 3983 CHANGE_VF("letterbox", b, DesktopInfo::desktop_aspectRatio(mplayerwindow)); 3867 3984 } 3868 3985 … … 3871 3988 3872 3989 pref->osd = v; 3873 tellmp( pausing_prefix() + " osd " + QString::number( pref->osd ) ); 3990 3991 proc->setPausingPrefix(pausing_prefix()); 3992 proc->setOSD(pref->osd); 3993 3874 3994 updateWidgets(); 3875 3995 } … … 3887 4007 3888 4008 if (mset.rotate != r) { 3889 mset.rotate = r; 3890 restartPlay(); 4009 if (proc->isMPlayer()) { 4010 mset.rotate = r; 4011 restartPlay(); 4012 } else { 4013 // MPV 4014 // Remove previous filter 4015 switch (mset.rotate) { 4016 case MediaSettings::Clockwise_flip: proc->changeVF("rotate", false, MediaSettings::Clockwise_flip); break; 4017 case MediaSettings::Clockwise: proc->changeVF("rotate", false, MediaSettings::Clockwise); break; 4018 case MediaSettings::Counterclockwise: proc->changeVF("rotate", false, MediaSettings::Counterclockwise); break; 4019 case MediaSettings::Counterclockwise_flip: proc->changeVF("rotate", false, MediaSettings::Counterclockwise_flip); break; 4020 } 4021 mset.rotate = r; 4022 // New filter 4023 switch (mset.rotate) { 4024 case MediaSettings::Clockwise_flip: proc->changeVF("rotate", true, MediaSettings::Clockwise_flip); break; 4025 case MediaSettings::Clockwise: proc->changeVF("rotate", true, MediaSettings::Clockwise); break; 4026 case MediaSettings::Counterclockwise: proc->changeVF("rotate", true, MediaSettings::Counterclockwise); break; 4027 case MediaSettings::Counterclockwise_flip: proc->changeVF("rotate", true, MediaSettings::Counterclockwise_flip); break; 4028 } 4029 } 3891 4030 } 3892 4031 } … … 4013 4152 } 4014 4153 4015 #if USE_MPLAYER_PANSCAN4016 void Core::changePanscan(double p) {4017 qDebug("Core::changePanscan: %f", p);4018 4019 if (p < 0.1) p = 0;4020 if (p > 1) p = 1;4021 4022 mset.panscan_factor = p;4023 tellmp(QString("panscan %1 1").arg(mset.panscan_factor));4024 displayMessage( QString("Panscan: %1").arg(mset.panscan_factor) );4025 }4026 4027 void Core::incPanscan() {4028 changePanscan(mset.panscan_factor + .1);4029 }4030 4031 void Core::decPanscan() {4032 changePanscan(mset.panscan_factor - .1);4033 }4034 #endif4035 4036 4154 void Core::showFilenameOnOSD() { 4037 tellmp("osd_show_property_text \"${filename}\" 5000 0"); 4155 proc->showFilenameOnOSD(); 4156 } 4157 4158 void Core::showTimeOnOSD() { 4159 proc->showTimeOnOSD(); 4038 4160 } 4039 4161 4040 4162 void Core::toggleDeinterlace() { 4041 4163 qDebug("Core::toggleDeinterlace"); 4042 4043 tellmp("step_property deinterlace"); 4044 } 4045 4046 void Core::changeUseAss(bool b) { 4047 qDebug("Core::changeUseAss: %d", b); 4048 4049 if (pref->use_ass_subtitles != b) { 4050 pref->use_ass_subtitles = b; 4164 proc->toggleDeinterlace(); 4165 } 4166 4167 void Core::changeUseCustomSubStyle(bool b) { 4168 qDebug("Core::changeUseCustomSubStyle: %d", b); 4169 4170 if (pref->enable_ass_styles != b) { 4171 pref->enable_ass_styles = b; 4051 4172 if (proc->isRunning()) restartPlay(); 4052 4173 } … … 4059 4180 pref->use_forced_subs_only = b; 4060 4181 //if (proc->isRunning()) restartPlay(); 4061 int v = 0; 4062 if (b) v = 1; 4063 tellmp( QString("forced_subs_only %1").arg(v) ); 4182 proc->setSubForcedOnly(b); 4064 4183 } 4065 4184 } … … 4093 4212 void Core::dvdnavUp() { 4094 4213 qDebug("Core::dvdnavUp"); 4095 tellmp("dvdnavup");4214 up"); 4096 4215 } 4097 4216 4098 4217 void Core::dvdnavDown() { 4099 4218 qDebug("Core::dvdnavDown"); 4100 tellmp("dvdnavdown");4219 down"); 4101 4220 } 4102 4221 4103 4222 void Core::dvdnavLeft() { 4104 4223 qDebug("Core::dvdnavLeft"); 4105 tellmp("dvdnavleft");4224 left"); 4106 4225 } 4107 4226 4108 4227 void Core::dvdnavRight() { 4109 4228 qDebug("Core::dvdnavRight"); 4110 tellmp("dvdnavright");4229 right"); 4111 4230 } 4112 4231 4113 4232 void Core::dvdnavMenu() { 4114 4233 qDebug("Core::dvdnavMenu"); 4115 tellmp("dvdnavmenu");4234 menu"); 4116 4235 } 4117 4236 4118 4237 void Core::dvdnavSelect() { 4119 4238 qDebug("Core::dvdnavSelect"); 4120 tellmp("dvdnavselect");4239 select"); 4121 4240 } 4122 4241 4123 4242 void Core::dvdnavPrev() { 4124 4243 qDebug("Core::dvdnavPrev"); 4125 tellmp("dvdnavprev");4244 prev"); 4126 4245 } 4127 4246 … … 4130 4249 4131 4250 if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:"))) { 4132 //QPoint p = mplayerwindow->videoLayer()->mapFromGlobal(QCursor::pos()); 4133 //tellmp(QString("set_mouse_pos %1 %2").arg(p.x()).arg(p.y())); 4134 tellmp("dvdnav mouse"); 4251 proc->discButtonPressed("mouse"); 4135 4252 } 4136 4253 } … … 4147 4264 4148 4265 void Core::displayScreenshotName(QString filename) { 4149 qDebug("Core::displayScreenshotName"); 4150 //QString text = tr("Screenshot saved as %1").arg(filename); 4151 QString text = QString("Screenshot saved as %1").arg(filename); 4152 4266 qDebug("Core::displayScreenshotName: %s", filename.toUtf8().constData()); 4267 4268 QFileInfo fi(filename); 4269 4270 QString text = tr("Screenshot saved as %1").arg(fi.fileName()); 4271 //QString text = QString("Screenshot saved as %1").arg(fi.fileName()); 4272 4273 #ifdef MPLAYER2_SUPPORT 4153 4274 if (MplayerVersion::isMplayer2()) { 4154 4275 displayTextOnOSD(text, 3000, 1, ""); 4155 4276 } 4156 4277 else 4278 4157 4279 if (MplayerVersion::isMplayerAtLeast(27665)) { 4158 4280 displayTextOnOSD(text, 3000, 1, "pausing_keep_force"); … … 4174 4296 4175 4297 void Core::displayBuffering() { 4176 emit showMessage(tr("Buffering...")); 4298 setState(Buffering); 4299 // emit showMessage(tr("Buffering...")); 4300 } 4301 4302 void Core::displayPlaying() { 4303 qDebug("Core::displayPlaying"); 4304 setState(Buffering); 4305 emit showMessage(tr("Starting..."), 60000); 4177 4306 } 4178 4307 … … 4264 4393 #endif 4265 4394 4266 if (( state == Playing) && (change_volume_after_unpause)) {4395 if ((state == Playing) && (change_volume_after_unpause)) { 4267 4396 // Delayed volume change 4268 4397 qDebug("Core::watchState: delayed volume change"); 4269 4398 int volume = (pref->global_volume ? pref->volume : mset.volume); 4270 tellmp("volume " + QString::number(volume) + " 1");4399 ); 4271 4400 change_volume_after_unpause = false; 4272 4401 } … … 4324 4453 #endif 4325 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4326 4464 #if NOTIFY_AUDIO_CHANGES 4327 4465 void Core::initAudioTrack(const Tracks & audios) { … … 4406 4544 restore_subs = false; 4407 4545 just_loaded_external_subs = false; 4408 4546 4409 4547 QFileInfo fi(mset.external_subtitles); 4410 if (fi.suffix().toLower() != "idx") { 4548 bool is_idx = (fi.suffix().toLower() == "idx"); 4549 if (proc->isMPV()) is_idx = false; // Hack to ignore the idx extension with mpv 4550 4551 if (!is_idx) { 4411 4552 // The loaded subtitle file is the last one, so 4412 4553 // try to select that one. … … 4466 4607 } 4467 4608 end: 4609 4610 4611 4612 4468 4613 updateWidgets(); 4469 4614 } … … 4472 4617 qDebug("Core::setSubtitleTrackAgain"); 4473 4618 changeSubtitle( mset.current_sub_id ); 4619 4620 4621 4622 4623 4624 4625 4626 4627 4474 4628 } 4475 4629 #endif … … 4489 4643 4490 4644 void Core::askForInfo() { 4491 if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:"))) { 4492 tellmp( pausing_prefix() + " get_property length"); 4645 if (proc->isMPlayer()) { 4646 if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:"))) { 4647 proc->setPausingPrefix(pausing_prefix()); 4648 proc->askForLength(); 4649 } 4493 4650 } 4494 4651 } 4495 4652 4496 4653 void Core::dvdnavUpdateMousePos(QPoint pos) { 4497 //qDebug("Core::dvdnavUpdateMousePos"); 4654 #if 0 4655 bool under_mouse = mplayerwindow->videoLayer()->underMouse(); 4656 4657 qDebug("Core::dvdnavUpdateMousePos: %d %d", pos.x(), pos.y()); 4658 qDebug("Core::dvdnavUpdateMousePos: state: %d", state()); 4659 qDebug("Core::dvdnavUpdateMousePos: filename: %s", mdat.filename.toUtf8().constData()); 4660 qDebug("Core::dvdnavUpdateMousePos: dvdnav_title_is_menu: %d", dvdnav_title_is_menu); 4661 qDebug("Core::dvdnavUpdateMousePos: under mouse: %d", under_mouse); 4662 #endif 4498 4663 if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:")) && (dvdnav_title_is_menu)) { 4499 if (mplayerwindow->videoLayer()->underMouse()) {4500 tellmp(QString("set_mouse_pos %1 %2").arg(pos.x()).arg(pos.y()));4501 }4664 ) { 4665 )); 4666 } 4502 4667 } 4503 4668 } … … 4511 4676 qDebug("Core::dvdTitleIsMovie"); 4512 4677 dvdnav_title_is_menu = false; 4513 4514 4678 } 4515 4679 #endif … … 4518 4682 qDebug("Core::pausing_prefix"); 4519 4683 4684 4520 4685 if (MplayerVersion::isMplayer2()) { 4521 4686 return QString::null; 4522 4687 } 4523 4688 else 4689 4524 4690 if ( (pref->use_pausing_keep_force) && 4525 4691 (MplayerVersion::isMplayerAtLeast(27665)) ) … … 4531 4697 } 4532 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4533 4740 #include "moc_core.cpp"
Note:
See TracChangeset
for help on using the changeset viewer.
