240
244
DiscName::test();
247
#ifdef YOUTUBE_SUPPORT
244
248
yt = new RetrieveYoutubeUrl(this);
245
249
connect(yt, SIGNAL(gotPreferredUrl(const QString &)), this, SLOT(openYT(const QString &)));
246
250
connect(yt, SIGNAL(connecting(QString)), this, SLOT(connectingToYT(QString)));
715
719
mset.current_title_id = title;
716
#if GENERIC_CHAPTER_SUPPORT
717
720
mset.current_chapter_id = firstChapter();
719
mset.current_chapter_id = dvdFirstChapter();
721
721
mset.current_angle_id = 1;
723
723
/* initializeMenus(); */
782
782
void Core::openStream(QString name) {
783
783
qDebug("Core::openStream: '%s'", name.toUtf8().data());
786
if (name.startsWith("http://www.youtube.com/watch?v=")) {
785
#ifdef YOUTUBE_SUPPORT
786
if (name.contains("youtube.com/watch", Qt::CaseInsensitive) ||
787
name.contains("youtu.be/", Qt::CaseInsensitive) ||
788
name.contains("y2u.be/", Qt::CaseInsensitive) )
787
790
qDebug("Core::openStream: youtube url detected");
791
if (name.startsWith("www.youtube.com")) name = "http://" + name;
792
if (name.startsWith("youtube.com")) name = "http://www." + name;
793
if (name.startsWith("youtu.be")) name = "http://" + name;
794
if (name.startsWith("y2u.be")) name = "http://" + name;
788
795
yt->setPreferredQuality( (RetrieveYoutubeUrl::Quality) pref->yt_quality );
789
796
yt->fetchPage(name);
905
912
int start_sec = (int) mset.current_sec;
906
913
if (seek > -1) start_sec = seek;
915
#ifdef YOUTUBE_SUPPORT
909
916
// Avoid to pass to mplayer the youtube page url
910
917
if (mdat.type == TYPE_STREAM) {
911
918
if (mdat.filename == yt->origUrl()) {
981
#if GENERIC_CHAPTER_SUPPORT
982
if (mdat.chapters > 0) {
985
if (mdat.mkv_chapters > 0) {
988
if (mdat.n_chapters > 0) {
987
989
// Just to show the first chapter checked in the menu
988
990
mset.current_chapter_id = firstChapter();
1498
1502
proc->addArgument("-identify");
1500
#if GENERIC_CHAPTER_SUPPORT
1501
1504
if (MplayerVersion::isMplayerAtLeast(27667)) {
1502
1505
// From r27667 the number of chapters can be obtained from ID_CHAPTERS
1503
1506
mset.current_chapter_id = 0; // Reset chapters
1506
1508
// We need this to get info about mkv chapters
1508
1510
proc->addArgument("-msglevel");
1514
1516
// (time would be relative to chapter)
1515
1517
mset.current_chapter_id = 0;
1517
#if GENERIC_CHAPTER_SUPPORT
1521
1521
proc->addArgument("-slave");
1523
1523
if (!pref->vo.isEmpty()) {
1637
1637
#define WINIDFROMHWND(hwnd) ( ( hwnd ) - 0x80000000UL )
1638
1638
proc->addArgument( QString::number( WINIDFROMHWND( (int) mplayerwindow->videoLayer()->winId() ) ));
1640
proc->addArgument( QString::number( (int) mplayerwindow->videoLayer()->winId() ) );
1640
proc->addArgument( QString::number( (qint64) mplayerwindow->videoLayer()->winId() ) );
1643
1643
#if USE_COLORKEY
1918
1918
proc->addArgument("-chapter");
1919
1919
int chapter = mset.current_chapter_id;
1920
1920
// Fix for older versions of mplayer:
1921
#if GENERIC_CHAPTER_SUPPORT
1922
1921
if ((mdat.type == TYPE_DVD) && (firstChapter() == 0)) chapter++;
1924
if ((mdat.type == TYPE_DVD) && (dvdFirstChapter() == 0)) chapter++;
1926
1922
proc->addArgument( QString::number( chapter ) );
2046
if (mset.current_unsharp != 0) {
2047
proc->addArgument("-vf-add");
2048
if (mset.current_unsharp == 1) {
2049
proc->addArgument( pref->filters->item("blur").filter() );
2051
proc->addArgument( pref->filters->item("sharpen").filter() );
2050
2056
if (mset.deblock_filter) {
2051
2057
proc->addArgument("-vf-add");
2058
2064
proc->addArgument( "pp=dr" );
2068
if (mset.gradfun_filter) {
2069
proc->addArgument("-vf-add");
2070
proc->addArgument( pref->filters->item("gradfun").filter() );
2062
2074
if (mset.upscaling_filter) {
2063
2075
int width = DesktopInfo::desktop_size(mplayerwindow).width();
2340
QEventLoop eventLoop;
2342
connect(proc, SIGNAL(processExited()), &eventLoop, SLOT(quit()));
2346
QTimer::singleShot(5000, &eventLoop, SLOT(quit()));
2347
eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
2349
if (proc->isRunning()) {
2350
qWarning("Core::stopMplayer: process didn't finish. Killing it...");
2327
2354
tellmp("quit");
2329
2356
qDebug("Core::stopMplayer: Waiting mplayer to finish...");
2662
void Core::toggleGradfun() {
2663
toggleGradfun( !mset.gradfun_filter );
2666
void Core::toggleGradfun(bool b) {
2667
qDebug("Core::toggleGradfun: %d", b);
2668
if ( b != mset.gradfun_filter) {
2669
mset.gradfun_filter = b;
2634
2674
void Core::toggleNoise() {
2635
2675
toggleNoise( !mset.noise_filter );
2706
void Core::changeUnsharp(int id) {
2707
qDebug( "Core::changeUnsharp: %d", id );
2708
if (id != mset.current_unsharp) {
2709
mset.current_unsharp = id;
2666
2714
void Core::changeUpscale(bool b) {
2667
2715
qDebug( "Core::changeUpscale: %d", b );
2668
2716
if (mset.upscaling_filter != b) {
3409
3457
void Core::changeChapter(int ID) {
3410
3458
qDebug("Core::changeChapter: ID: %d", ID);
3412
if (ID != mset.current_chapter_id) {
3413
//if (QFileInfo(mdat.filename).extension().lower()=="mkv") {
3414
#if GENERIC_CHAPTER_SUPPORT
3415
if (mdat.type != TYPE_DVD) {
3417
if (mdat.mkv_chapters > 0) {
3418
// mkv doesn't require to restart
3460
if (mdat.type != TYPE_DVD) {
3462
if (mdat.chapters.find(ID) > -1) {
3463
double start = mdat.chapters.item(ID).start();
3464
qDebug("Core::changeChapter: start: %f", start);
3466
mset.current_chapter_id = ID;
3420
3469
tellmp("seek_chapter " + QString::number(ID) +" 1");
3421
3470
mset.current_chapter_id = ID;
3424
3476
#if SMART_DVD_CHAPTERS
3425
if (pref->cache_for_dvds == 0) {
3477
if (pref->cache_for_dvds == 0) {
3427
if (pref->fast_chapter_change) {
3479
if (pref->fast_chapter_change) {
3429
tellmp("seek_chapter " + QString::number(ID) +" 1");
3430
mset.current_chapter_id = ID;
3434
mset.current_chapter_id = ID;
3436
mset.current_sec = 0;
3481
tellmp("seek_chapter " + QString::number(ID) +" 1");
3482
mset.current_chapter_id = ID;
3486
mset.current_chapter_id = ID;
3488
mset.current_sec = 0;
3451
#if !GENERIC_CHAPTER_SUPPORT
3452
int Core::dvdFirstChapter() {
3453
// TODO: check if the change really happens in the same version as mkv
3454
return firstChapter();
3458
3502
void Core::prevChapter() {
3459
3503
qDebug("Core::prevChapter");
3461
#if GENERIC_CHAPTER_SUPPORT
3462
3505
int last_chapter = 0;
3463
3506
int first_chapter = firstChapter();
3465
last_chapter = mdat.chapters + firstChapter() - 1;
3467
int ID = mset.current_chapter_id - 1;
3468
if (ID < first_chapter) {
3473
int last_chapter = 0;
3474
bool matroshka = (mdat.mkv_chapters > 0);
3476
int first_chapter = dvdFirstChapter();
3477
if (matroshka) first_chapter = firstChapter();
3479
// Matroshka chapters
3480
if (matroshka) last_chapter = mdat.mkv_chapters + firstChapter() - 1;
3483
if (mset.current_title_id > 0) {
3484
last_chapter = mdat.titles.item(mset.current_title_id).chapters() + dvdFirstChapter() -1;
3487
int ID = mset.current_chapter_id - 1;
3488
if (ID < first_chapter) {
3508
int ID = mdat.chapters.itemBeforeTime(mset.current_sec).ID();
3511
last_chapter = mdat.n_chapters + firstChapter() - 1;
3513
ID = mset.current_chapter_id - 1;
3514
if (ID < first_chapter) {
3495
3522
void Core::nextChapter() {
3496
3523
qDebug("Core::nextChapter");
3498
#if GENERIC_CHAPTER_SUPPORT
3499
int last_chapter = 0;
3500
last_chapter = mdat.chapters + firstChapter() - 1;
3502
int ID = mset.current_chapter_id + 1;
3503
if (ID > last_chapter) {
3504
ID = firstChapter();
3508
int last_chapter = 0;
3509
bool matroshka = (mdat.mkv_chapters > 0);
3511
// Matroshka chapters
3512
if (matroshka) last_chapter = mdat.mkv_chapters + firstChapter() - 1;
3515
if (mset.current_title_id > 0) {
3516
last_chapter = mdat.titles.item(mset.current_title_id).chapters() + dvdFirstChapter() - 1;
3519
int ID = mset.current_chapter_id + 1;
3520
if (ID > last_chapter) {
3521
if (matroshka) ID = firstChapter(); else ID = dvdFirstChapter();
3525
int last_chapter = mdat.n_chapters + firstChapter() - 1;
3527
int ID = mdat.chapters.itemAfterTime(mset.current_sec).ID();
3530
ID = mset.current_chapter_id + 1;
3531
if (ID > last_chapter) {
3532
ID = firstChapter();
3527
3539
void Core::changeAngle(int ID) {