Changeset 163 for smplayer/vendor/current/src/core.cpp
- Timestamp:
- May 15, 2014, 7:53:54 PM (12 years ago)
- File:
-
- 1 edited
-
smplayer/vendor/current/src/core.cpp (modified) (40 diffs)
Legend:
- Unmodified
- Added
- Removed
-
smplayer/vendor/current/src/core.cpp
r154 r163 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 3Ricardo 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 … … 224 224 this, SLOT(dvdTitleIsMovie()) ); 225 225 #endif 226 226 227 connect( proc, SIGNAL(receivedForbiddenText()), this, SIGNAL(receivedForbidden()) ); 228 227 229 connect( this, SIGNAL(stateChanged(Core::State)), 228 230 this, SLOT(watchState(Core::State)) ); … … 245 247 246 248 #if DVDNAV_SUPPORT 247 connect( mplayerwindow , SIGNAL(mouseMoved(QPoint)),249 connect( mplayerwindow 248 250 this, SLOT(dvdnavUpdateMousePos(QPoint)) ); 249 251 #endif … … 258 260 // Windows or OS2 screensaver 259 261 win_screensaver = new WinScreenSaver(); 260 #endif 261 #endif 262 263 #if DISCNAME_TEST 264 DiscName::test(); 262 connect( this, SIGNAL(aboutToStartPlaying()), this, SLOT(disableScreensaver()) ); 263 connect( proc, SIGNAL(processExited()), this, SLOT(enableScreensaver()) ); 264 connect( proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(enableScreensaver()) ); 265 #endif 265 266 #endif 266 267 … … 403 404 if (!prefix.isEmpty()) str = prefix + " " + str; 404 405 qDebug("Core::displayTextOnOSD: command: '%s'", str.toUtf8().constData()); 405 proc->write(str.to Ascii());406 proc->write(str.to()); 406 407 } 407 408 } … … 468 469 } 469 470 else 471 472 473 474 475 476 477 470 478 if (file.toLower().startsWith("vcd:")) { 471 479 qDebug("Core::open: * identified as vcd"); … … 540 548 541 549 void Core::YTNoVideoUrl() { 542 emit showMessage( tr("Unable to locate the url of the video") ); 543 } 550 emit showMessage( tr("Unable to locate the URL of the video") ); 551 } 552 #endif 553 554 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) 555 #ifdef SCREENSAVER_OFF 556 void Core::enableScreensaver() { 557 qDebug("Core::enableScreensaver"); 558 if (pref->turn_screensaver_off) { 559 win_screensaver->enable(); 560 } 561 } 562 563 void Core::disableScreensaver() { 564 qDebug("Core::disableScreensaver"); 565 if (pref->turn_screensaver_off) { 566 win_screensaver->disable(); 567 } 568 } 569 #endif 544 570 #endif 545 571 … … 606 632 if ( (fi.exists()) && (fi.isDir()) ) { 607 633 pref->dvd_directory = directory; 608 pref->play_dvd_from_hd = TRUE;634 pref->play_dvd_from_hd = ; 609 635 openDVD(); 610 636 } else { … … 615 641 } 616 642 } else { 617 pref->play_dvd_from_hd = FALSE;643 pref->play_dvd_from_hd = ; 618 644 openDVD(); 619 645 } … … 756 782 } 757 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 758 834 void Core::openTV(QString channel_id) { 759 835 qDebug("Core::openTV: '%s'", channel_id.toUtf8().constData()); … … 814 890 815 891 #ifdef YOUTUBE_SUPPORT 816 if (name.contains("youtube.com/watch", Qt::CaseInsensitive) || 817 name.contains("youtu.be/", Qt::CaseInsensitive) || 818 name.contains("y2u.be/", Qt::CaseInsensitive) ) 819 { 820 qDebug("Core::openStream: youtube url detected"); 821 if (name.startsWith("www.youtube.com")) name = "http://" + name; 822 if (name.startsWith("youtube.com")) name = "http://www." + name; 823 if (name.startsWith("youtu.be")) name = "http://" + name; 824 if (name.startsWith("y2u.be")) name = "http://" + name; 892 // Check if the stream is a youtube url 893 QString yt_full_url = yt->fullUrl(name); 894 if (!yt_full_url.isEmpty()) { 895 qDebug("Core::openStream: youtube url detected: %s", yt_full_url.toLatin1().constData()); 896 name = yt_full_url; 825 897 yt->setPreferredQuality( (RetrieveYoutubeUrl::Quality) pref->yt_quality ); 826 898 qDebug("Core::openStream: user_agent: '%s'", pref->yt_user_agent.toUtf8().constData()); 827 899 if (!pref->yt_user_agent.isEmpty()) yt->setUserAgent(pref->yt_user_agent); 828 900 #ifdef YT_USE_SCRIPT 829 YTSig::setScriptFile( Paths::configPath() + "/yt code.script" );901 YTSig::setScriptFile( Paths::configPath() + "/yt" ); 830 902 #endif 831 903 yt->fetchPage(name); … … 1026 1098 } 1027 1099 1028 mdat.initialized = TRUE;1100 mdat.initialized = ; 1029 1101 1030 1102 // MPlayer doesn't display the length in ID_LENGTH for audio CDs... … … 1132 1204 changeAspectRatio(mset.aspect_ratio_id); 1133 1205 1134 if (pref->global_volume) { 1135 bool was_muted = pref->mute; 1136 setVolume( pref->volume, true); 1137 if (was_muted) mute(true); 1206 if (pref->mplayer_additional_options.contains("-volume")) { 1207 qDebug("Core::finishRestart: don't set volume since -volume is used"); 1138 1208 } else { 1139 bool was_muted = mset.mute; 1140 setVolume( mset.volume, true ); 1141 if (was_muted) mute(true); 1209 if (pref->global_volume) { 1210 bool was_muted = pref->mute; 1211 setVolume( pref->volume, true); 1212 if (was_muted) mute(true); 1213 } else { 1214 bool was_muted = mset.mute; 1215 setVolume( mset.volume, true ); 1216 if (was_muted) mute(true); 1217 } 1142 1218 } 1143 1219 … … 1208 1284 1209 1285 1210 void Core::play() 1211 { 1286 void Core::play() { 1212 1287 qDebug("Core::play"); 1213 1288 1214 1289 if ((proc->isRunning()) && (state()==Paused)) { 1215 1290 tellmp("pause"); // Unpauses 1216 } 1291 } 1217 1292 else 1218 1293 if ((proc->isRunning()) && (state()==Playing)) { … … 1229 1304 */ 1230 1305 restartPlay(); 1231 } 1232 } 1306 } else { 1307 emit noFileToPlay(); 1308 } 1309 } 1233 1310 } 1234 1311 … … 1302 1379 { 1303 1380 qDebug("Core::processFinished"); 1304 1305 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)1306 #ifdef SCREENSAVER_OFF1307 // Restores the Windows or OS2 screensaver1308 if (pref->turn_screensaver_off) {1309 win_screensaver->enable();1310 }1311 #endif1312 #endif1313 1314 1381 qDebug("Core::processFinished: we_are_restarting: %d", we_are_restarting); 1315 1382 … … 1394 1461 #endif 1395 1462 yt->close(); 1396 #endif1397 1398 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)1399 #ifdef SCREENSAVER_OFF1400 // Disable the Windows or OS2 screensaver1401 if (pref->turn_screensaver_off) {1402 win_screensaver->disable();1403 }1404 #endif1405 1463 #endif 1406 1464 … … 1429 1487 qDebug("Core::startMplayer: url path: '%s'", url.path().toUtf8().constData()); 1430 1488 1431 QRegExp rx("\\.ram$|\\.asx$|\\.m3u$|\\.pls$", Qt::CaseInsensitive); 1432 url_is_playlist = (rx.indexIn(url.path()) != -1); 1489 if (url.scheme().toLower() != "ffmpeg") { 1490 QRegExp rx("\\.ram$|\\.asx$|\\.m3u$|\\.m3u8$|\\.pls$", Qt::CaseInsensitive); 1491 url_is_playlist = (rx.indexIn(url.path()) != -1); 1492 } 1433 1493 } 1434 1494 qDebug("Core::startMplayer: url_is_playlist: %d", url_is_playlist); 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1435 1515 1436 1516 … … 1736 1816 proc->addArgument( QString::number(mset.sub_scale_ass) ); 1737 1817 1818 1819 1820 1821 1738 1822 if (!pref->force_ass_styles) { 1739 1823 // Load the styles.ass file … … 1759 1843 // Use the same font for OSD 1760 1844 #if !defined(Q_OS_OS2) 1761 if ( !pref->ass_styles.fontname.isEmpty()) {1845 if ()) { 1762 1846 #ifdef USE_FONTCONFIG_OPTIONS 1763 1847 if (!pref->mplayer_is_mplayer2) { // -fontconfig removed from mplayer2 … … 1861 1945 } 1862 1946 1863 if (mset.current_audio_id != MediaSettings::NoneSelected) { 1864 // Workaround for MPlayer bug #1321 (http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1321) 1865 if (mdat.audios.numItems() != 1) { 1866 proc->addArgument("-aid"); 1867 proc->addArgument( QString::number( mset.current_audio_id ) ); 1947 if (mset.external_audio.isEmpty()) { 1948 if (mset.current_audio_id != MediaSettings::NoneSelected) { 1949 // Workaround for MPlayer bug #1321 (http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1321) 1950 if (mdat.audios.numItems() != 1) { 1951 proc->addArgument("-aid"); 1952 proc->addArgument( QString::number( mset.current_audio_id ) ); 1953 } 1868 1954 } 1869 1955 } … … 1968 2054 bool use_volume_option = (MplayerVersion::isMplayerAtLeast(27872)); 1969 2055 1970 if (pref->global_volume) { 1971 if (use_volume_option) { 1972 proc->addArgument("-volume"); 1973 proc->addArgument( QString::number( pref->volume ) ); 1974 } 2056 if (pref->mplayer_additional_options.contains("-volume")) { 2057 qDebug("Core::startMplayer: don't set volume since -volume is used"); 1975 2058 } else { 1976 if (use_volume_option) { 1977 proc->addArgument("-volume"); 1978 // Note: mset.volume may not be right, it can be the volume of the previous video if 1979 // playing a new one, but I think it's better to use anyway the current volume on 1980 // startup than set it to 0 or something. 1981 // The right volume will be set later, when the video starts to play. 1982 proc->addArgument( QString::number( mset.volume ) ); 2059 if (pref->global_volume) { 2060 if (use_volume_option) { 2061 proc->addArgument("-volume"); 2062 proc->addArgument( QString::number( pref->volume ) ); 2063 } 2064 } else { 2065 if (use_volume_option) { 2066 proc->addArgument("-volume"); 2067 // Note: mset.volume may not be right, it can be the volume of the previous video if 2068 // playing a new one, but I think it's better to use anyway the current volume on 2069 // startup than set it to 0 or something. 2070 // The right volume will be set later, when the video starts to play. 2071 proc->addArgument( QString::number( mset.volume ) ); 2072 } 1983 2073 } 1984 2074 } … … 2019 2109 case TYPE_FILE : cache = pref->cache_for_files; break; 2020 2110 case TYPE_DVD : cache = pref->cache_for_dvds; 2021 #if DVDNAV_SUPPORT2111 #if DVDNAV_SUPPORT 2022 2112 if (file.startsWith("dvdnav:")) cache = 0; 2023 #endif2113 #endif 2024 2114 break; 2025 2115 case TYPE_STREAM : cache = pref->cache_for_streams; break; … … 2027 2117 case TYPE_AUDIO_CD : cache = pref->cache_for_audiocds; break; 2028 2118 case TYPE_TV : cache = pref->cache_for_tv; break; 2119 2120 2121 2029 2122 default: cache = 0; 2030 2123 } … … 2312 2405 if (pref->use_audio_equalizer) { 2313 2406 if (!af.isEmpty()) af += ","; 2314 af += "equalizer=" + Helper::equalizerListToString(mset.audio_equalizer); 2407 AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : mset.audio_equalizer; 2408 af += "equalizer=" + Helper::equalizerListToString(l); 2315 2409 } 2316 2410 … … 2350 2444 QString basename = f.path() + "/" + f.completeBaseName(); 2351 2445 2352 qDebug("Core::startMplayer: file basename: '%s'", basename.toUtf8().data());2446 qDebug("Core::startMplayer: file basename: '%s'", basename.toUtf8().data()); 2353 2447 2354 2448 if (QFile::exists(basename+".edl")) … … 2419 2513 QString line_for_log = commandline + "\n"; 2420 2514 emit logLineAvailable(line_for_log); 2421 2515 2516 #ifdef Q_OS_WIN 2517 if (!pref->use_windowsfontdir) { 2518 QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); 2519 env.insert("FONTCONFIG_FILE", Paths::configPath() + "/fonts.conf"); 2520 proc->setProcessEnvironment(env); 2521 } 2522 #endif 2422 2523 if ( !proc->start() ) { 2423 2524 // error handling … … 2890 2991 2891 2992 void Core::incBrightness() { 2892 setBrightness(mset.brightness + 4);2993 setBrightness(mset.brightness + ); 2893 2994 } 2894 2995 2895 2996 void Core::decBrightness() { 2896 setBrightness(mset.brightness - 4);2997 setBrightness(mset.brightness - ); 2897 2998 } 2898 2999 2899 3000 void Core::incContrast() { 2900 setContrast(mset.contrast + 4);3001 setContrast(mset.contrast + ); 2901 3002 } 2902 3003 2903 3004 void Core::decContrast() { 2904 setContrast(mset.contrast - 4);3005 setContrast(mset.contrast - ); 2905 3006 } 2906 3007 2907 3008 void Core::incGamma() { 2908 setGamma(mset.gamma + 4);3009 setGamma(mset.gamma + ); 2909 3010 } 2910 3011 2911 3012 void Core::decGamma() { 2912 setGamma(mset.gamma - 4);3013 setGamma(mset.gamma - ); 2913 3014 } 2914 3015 2915 3016 void Core::incHue() { 2916 setHue(mset.hue + 4);3017 setHue(mset.hue + ); 2917 3018 } 2918 3019 2919 3020 void Core::decHue() { 2920 setHue(mset.hue - 4);3021 setHue(mset.hue - ); 2921 3022 } 2922 3023 2923 3024 void Core::incSaturation() { 2924 setSaturation(mset.saturation + 4);3025 setSaturation(mset.saturation + ); 2925 3026 } 2926 3027 2927 3028 void Core::decSaturation() { 2928 setSaturation(mset.saturation - 4);3029 setSaturation(mset.saturation - ); 2929 3030 } 2930 3031 … … 3041 3142 void Core::incVolume() { 3042 3143 qDebug("Core::incVolume"); 3043 int new_vol = (pref->global_volume ? pref->volume + 4 : mset.volume + 4);3144 int new_vol = (pref->global_volume ? pref->volume + ); 3044 3145 setVolume(new_vol); 3045 3146 } … … 3047 3148 void Core::decVolume() { 3048 3149 qDebug("Core::incVolume"); 3049 int new_vol = (pref->global_volume ? pref->volume - 4 : mset.volume - 4);3150 int new_vol = (pref->global_volume ? pref->volume - ); 3050 3151 setVolume(new_vol); 3051 3152 } … … 3199 3300 // Audio equalizer functions 3200 3301 void Core::setAudioEqualizer(AudioEqualizerList values, bool restart) { 3201 mset.audio_equalizer = values; 3302 if (pref->global_audio_equalizer) { 3303 pref->audio_equalizer = values; 3304 } else { 3305 mset.audio_equalizer = values; 3306 } 3202 3307 3203 3308 if (!restart) { … … 3214 3319 3215 3320 void Core::updateAudioEqualizer() { 3216 setAudioEqualizer(mset.audio_equalizer); 3321 setAudioEqualizer(pref->global_audio_equalizer ? pref->audio_equalizer : mset.audio_equalizer); 3322 } 3323 3324 void Core::setAudioEq(int eq, int value) { 3325 if (pref->global_audio_equalizer) { 3326 pref->audio_equalizer[eq] = value; 3327 } else { 3328 mset.audio_equalizer[eq] = value; 3329 } 3330 updateAudioEqualizer(); 3217 3331 } 3218 3332 3219 3333 void Core::setAudioEq0(int value) { 3220 mset.audio_equalizer[0] = value; 3221 updateAudioEqualizer(); 3334 setAudioEq(0, value); 3222 3335 } 3223 3336 3224 3337 void Core::setAudioEq1(int value) { 3225 mset.audio_equalizer[1] = value; 3226 updateAudioEqualizer(); 3338 setAudioEq(1, value); 3227 3339 } 3228 3340 3229 3341 void Core::setAudioEq2(int value) { 3230 mset.audio_equalizer[2] = value; 3231 updateAudioEqualizer(); 3342 setAudioEq(2, value); 3232 3343 } 3233 3344 3234 3345 void Core::setAudioEq3(int value) { 3235 mset.audio_equalizer[3] = value; 3236 updateAudioEqualizer(); 3346 setAudioEq(3, value); 3237 3347 } 3238 3348 3239 3349 void Core::setAudioEq4(int value) { 3240 mset.audio_equalizer[4] = value; 3241 updateAudioEqualizer(); 3350 setAudioEq(4, value); 3242 3351 } 3243 3352 3244 3353 void Core::setAudioEq5(int value) { 3245 mset.audio_equalizer[5] = value; 3246 updateAudioEqualizer(); 3354 setAudioEq(5, value); 3247 3355 } 3248 3356 3249 3357 void Core::setAudioEq6(int value) { 3250 mset.audio_equalizer[6] = value; 3251 updateAudioEqualizer(); 3358 setAudioEq(6, value); 3252 3359 } 3253 3360 3254 3361 void Core::setAudioEq7(int value) { 3255 mset.audio_equalizer[7] = value; 3256 updateAudioEqualizer(); 3362 setAudioEq(7, value); 3257 3363 } 3258 3364 3259 3365 void Core::setAudioEq8(int value) { 3260 mset.audio_equalizer[8] = value; 3261 updateAudioEqualizer(); 3366 setAudioEq(8, value); 3262 3367 } 3263 3368 3264 3369 void Core::setAudioEq9(int value) { 3265 mset.audio_equalizer[9] = value; 3266 updateAudioEqualizer(); 3370 setAudioEq(9, value); 3267 3371 } 3268 3372 … … 3436 3540 // the volume is reduced if using -softvol-max. 3437 3541 3438 if (pref->global_volume) { 3439 setVolume( pref->volume, true); 3440 if (pref->mute) mute(true); 3542 if (pref->mplayer_additional_options.contains("-volume")) { 3543 qDebug("Core::changeAudio: don't set volume since -volume is used"); 3441 3544 } else { 3442 setVolume( mset.volume, true ); 3443 if (mset.mute) mute(true); // if muted, mute again 3545 if (pref->global_volume) { 3546 setVolume( pref->volume, true); 3547 if (pref->mute) mute(true); 3548 } else { 3549 setVolume( mset.volume, true ); 3550 if (mset.mute) mute(true); // if muted, mute again 3551 } 3444 3552 } 3445 3553 updateWidgets(); … … 3545 3653 else 3546 3654 if (mdat.type == TYPE_DVD) { 3547 #if DVDNAV_SUPPORT3655 #if DVDNAV_SUPPORT 3548 3656 if (mdat.filename.startsWith("dvdnav:")) { 3549 3657 tellmp("switch_title " + QString::number(ID)); 3550 3658 } else { 3551 #endif3659 #endif 3552 3660 DiscData disc_data = DiscName::split(mdat.filename); 3553 3661 disc_data.title = ID; … … 3555 3663 3556 3664 openDVD( DiscName::join(disc_data) ); 3557 #if DVDNAV_SUPPORT 3558 } 3559 #endif 3560 } 3665 #if DVDNAV_SUPPORT 3666 } 3667 #endif 3668 } 3669 #ifdef BLURAY_SUPPORT 3670 else 3671 if (mdat.type == TYPE_BLURAY) { 3672 //DiscName::test(); 3673 3674 DiscData disc_data = DiscName::split(mdat.filename); 3675 disc_data.title = ID; 3676 QString bluray_url = DiscName::join(disc_data); 3677 qDebug("Core::changeTitle: bluray_url: %s", bluray_url.toUtf8().constData()); 3678 openBluRay(bluray_url); 3679 } 3680 #endif 3561 3681 } 3562 3682 … … 3680 3800 << MediaSettings::Aspect54 // 1.25 3681 3801 << MediaSettings::Aspect43 // 1.33 3802 3682 3803 << MediaSettings::Aspect1410 // 1.4 3683 3804 << MediaSettings::Aspect32 // 1.5 … … 3709 3830 a = 2; 3710 3831 // See if we are done 3711 if (pref->wheel_function_cycle.testFlag(QFlag(a)))3832 if)) 3712 3833 done = true; 3713 3834 } … … 4084 4205 emit needResize( mset.win_width, mset.win_height ); 4085 4206 */ 4086 //mplayerwindow->showLogo( TRUE);4207 //mplayerwindow->showLogo(); 4087 4208 emit noVideo(); 4088 4209 } … … 4343 4464 void Core::durationChanged(double length) { 4344 4465 qDebug("Core::durationChanged: %f", length); 4345 mdat.duration = length; 4466 if (mdat.duration != length) { 4467 mdat.duration = length; 4468 emit newDuration(length); 4469 } 4346 4470 } 4347 4471 … … 4353 4477 4354 4478 void Core::dvdnavUpdateMousePos(QPoint pos) { 4479 4355 4480 if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:")) && (dvdnav_title_is_menu)) { 4356 4481 if (mplayerwindow->videoLayer()->underMouse()) { 4357 QPoint p = mplayerwindow->videoLayer()->mapFromParent(pos); 4358 tellmp(QString("set_mouse_pos %1 %2").arg(p.x()).arg(p.y())); 4482 tellmp(QString("set_mouse_pos %1 %2").arg(pos.x()).arg(pos.y())); 4359 4483 } 4360 4484 }
Note:
See TracChangeset
for help on using the changeset viewer.
