Ticket #1544: mythdvd_bookmark_v2.patch
File mythdvd_bookmark_v2.patch, 10.9 KB (added by , 20 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.cpp
980 980 deleteIter = deleteMap.begin(); 981 981 } 982 982 } 983 984 // need this til proper DVD bookmarking is implemented 985 if (!ringBuffer->isDVD()) 986 bookmarkseek = GetBookmark(); 983 984 if (ringBuffer->isDVD()) 985 ringBuffer->DVD()->JumpToTitle(false); 987 986 987 bookmarkseek = GetBookmark(); 988 988 989 return IsErrored() ? -1 : 0; 989 990 } 990 991 … … 2894 2895 GetDecoder()->setExactSeeks(false); 2895 2896 2896 2897 fftime = bookmarkseek; 2898 if (ringBuffer->isDVD()) 2899 GetDVDBookmark(); 2900 2897 2901 DoFastForward(); 2898 2902 fftime = 0; 2899 2903 2900 2904 GetDecoder()->setExactSeeks(seeks); 2901 2905 2902 2906 if (gContext->GetNumSetting("ClearSavedPosition", 1)) 2903 m_playbackinfo->SetBookmark(0); 2907 { 2908 if (ringBuffer->isDVD()) 2909 SetDVDBookmark(0); 2910 else 2911 m_playbackinfo->SetBookmark(0); 2912 } 2904 2913 } 2905 2914 2906 2915 commBreakMapLock.lock(); … … 3361 3370 if (!m_playbackinfo || !osd) 3362 3371 return; 3363 3372 3373 if (ringBuffer->isDVD()) 3374 { 3375 if (ringBuffer->InDVDMenuOrStillFrame()) 3376 SetDVDBookmark(0); 3377 else 3378 SetDVDBookmark(framesPlayed); 3379 } 3364 3380 m_playbackinfo->SetBookmark(framesPlayed); 3365 3381 osd->SetSettingsText(QObject::tr("Position Saved"), 1); 3366 3382 } … … 3370 3386 if (!m_playbackinfo || !osd) 3371 3387 return; 3372 3388 3373 m_playbackinfo->SetBookmark(0); 3389 if (ringBuffer->isDVD()) 3390 SetDVDBookmark(0); 3391 else 3392 m_playbackinfo->SetBookmark(0); 3374 3393 osd->SetSettingsText(QObject::tr("Position Cleared"), 1); 3375 3394 } 3376 3395 … … 3379 3398 if (!m_playbackinfo) 3380 3399 return 0; 3381 3400 3401 if (ringBuffer->isDVD()) 3402 return GetDVDBookmark(); 3403 3382 3404 return m_playbackinfo->GetBookmark(); 3383 3405 } 3384 3406 … … 5905 5927 ringBuffer->DVD()->GoToNextProgram(); 5906 5928 } 5907 5929 5930 long long NuppelVideoPlayer::GetDVDBookmark(void) const 5931 { 5932 if (!ringBuffer->isDVD()) 5933 return 0; 5934 5935 QStringList dvdbookmark = QStringList(); 5936 const char *name; 5937 const char *serialid; 5938 long long frames = 0; 5939 bool delbookmark, jumptotitle; 5940 delbookmark = jumptotitle = ringBuffer->DVD()->JumpToTitle(); 5941 if (m_playbackinfo && ringBuffer->isDVD()) 5942 { 5943 ringBuffer->DVD()->GetNameAndSerialNum(&name,&serialid); 5944 dvdbookmark = m_playbackinfo->GetDVDBookmark(QString(serialid), 5945 !delbookmark); 5946 if (!dvdbookmark.empty()) 5947 { 5948 QStringList::Iterator it = dvdbookmark.begin(); 5949 int title = atoi((*it).ascii()); 5950 frames = (long long)(atoi((*++it).ascii()) & 0xffffffffLL); 5951 if (jumptotitle) 5952 { 5953 ringBuffer->DVD()->PlayTitleAndPart(title, 1); 5954 int audiotrack = atoi((*++it).ascii()); 5955 int subtitletrack = atoi((*++it).ascii()); 5956 ringBuffer->DVD()->SetTrack(kTrackTypeAudio, audiotrack); 5957 ringBuffer->DVD()->SetTrack(kTrackTypeSubtitle, subtitletrack); 5958 } 5959 ringBuffer->DVD()->JumpToTitle(true); 5960 } 5961 } 5962 return frames; 5963 } 5964 5965 void NuppelVideoPlayer::SetDVDBookmark(long long frames) 5966 { 5967 if (!ringBuffer->isDVD()) 5968 return; 5969 5970 QStringList fields; 5971 const char *name; 5972 const char *serialid; 5973 int title = 0; 5974 int part; 5975 int audiotrack = -1; 5976 int subtitletrack = -1; 5977 ringBuffer->DVD()->GetNameAndSerialNum(&name, &serialid); 5978 5979 if (!ringBuffer->InDVDMenuOrStillFrame() && 5980 ringBuffer->DVD()->GetTotalTimeOfTitle() > 300 && 5981 frames > 0) 5982 { 5983 audiotrack = GetTrack(kTrackTypeAudio); 5984 if (GetCaptionMode()) 5985 subtitletrack = GetTrack(kTrackTypeSubtitle); 5986 ringBuffer->DVD()->GetPartAndTitle(part,title); 5987 } 5988 5989 if (m_playbackinfo) 5990 { 5991 fields += QString(serialid); 5992 fields += QString(name); 5993 fields += QString("%1").arg(title); 5994 fields += QString("%1").arg(audiotrack); 5995 fields += QString("%1").arg(subtitletrack); 5996 fields += QString("%1").arg(frames); 5997 m_playbackinfo->SetDVDBookmark(fields); 5998 } 5999 } 6000 5908 6001 // EIA-708 caption support -- begin 5909 6002 void NuppelVideoPlayer::SetCurrentWindow(uint service_num, int window_id) 5910 6003 { -
libs/libmythtv/NuppelVideoPlayer.h
477 477 478 478 // Private DVD stuff 479 479 void DisplayDVDButton(void); 480 long long GetDVDBookmark(void) const; 481 void SetDVDBookmark(long long frames); 480 482 481 483 private: 482 484 VideoOutputType forceVideoOutput; -
libs/libmythtv/tv_play.cpp
2398 2398 DoSeek(jumptime * 60, tr("Jump Ahead")); 2399 2399 } 2400 2400 } 2401 else if (action == "JUMPBKMRK" )2401 else if (action == "JUMPBKMRK" && !prbuffer->isDVD()) 2402 2402 { 2403 2403 int bookmark = activenvp->GetBookmark(); 2404 2404 if (bookmark > frameRate) … … 2483 2483 { 2484 2484 nvp->Pause(); 2485 2485 2486 QString vmessage = tr("You are exiting this video"); 2486 QString vmessage; 2487 if (prbuffer->isDVD()) 2488 vmessage = tr("You are exiting this DVD"); 2489 else 2490 vmessage = tr("You are exiting this video"); 2487 2491 2488 2492 QStringList voptions; 2489 voptions += tr("Exit to the menu"); 2493 if (prbuffer->isDVD()) 2494 { 2495 voptions += tr("Save this position and go to the menu"); 2496 voptions += tr("Do not save, just exit to the menu"); 2497 } 2498 else 2499 voptions += tr("Exit to the menu"); 2500 2490 2501 voptions += tr("Keep watching"); 2491 dialogname = "videoexitplayoptions"; 2502 if (prbuffer->isDVD()) 2503 dialogname = "exitplayoptions"; 2504 else 2505 dialogname = "videoexitplayoptions"; 2492 2506 if (GetOSD()) 2493 2507 GetOSD()->NewDialogBox(dialogname, vmessage, voptions, 0); 2494 2508 } … … 2638 2652 { 2639 2653 if (!was_doing_ff_rew) 2640 2654 { 2655 if (prbuffer->isDVD()) 2656 prbuffer->DVD()->JumpToTitle(false); 2657 2641 2658 if (gContext->GetNumSetting("AltClearSavedPosition", 1) 2642 2659 && nvp->GetBookmark()) 2643 2660 nvp->ClearBookmark(); -
libs/libmythtv/programinfo.h
177 177 // DB gets 178 178 long long GetFilesize(void); 179 179 long long GetBookmark(void) const; 180 QStringList GetDVDBookmark(QString serialid, bool delbookmark) const; 180 181 bool IsEditing(void) const; 181 182 bool IsCommFlagged(void) const; 182 183 bool IsInUse(QString &byWho) const; … … 191 192 // DB sets 192 193 void SetFilesize(long long fsize); 193 194 void SetBookmark(long long pos) const; 195 void SetDVDBookmark(QStringList fields) const; 194 196 void SetEditing(bool edit) const; 195 197 void SetTranscoded(int transFlag) const; 196 198 void SetDeleteFlag(bool deleteFlag) const; -
libs/libmythtv/programinfo.cpp
1703 1703 return pos; 1704 1704 } 1705 1705 1706 /** \fn ProgramInfo::GetDVDBookmark(QString serialid,bool delbookmark) const 1707 * \brief Queries "dvdbookmark" table for bookmarking using DVD 1708 * serial number. Deletes old dvd bookmarks if "delete" is true. 1709 * 1710 * \return list containing title,part,frame number 1711 */ 1712 QStringList ProgramInfo::GetDVDBookmark(QString serialid, bool delbookmark) const 1713 { 1714 QStringList fields = QStringList(); 1715 MSqlQuery query(MSqlQuery::InitCon()); 1716 1717 if (ignoreBookmark) 1718 return fields; 1719 1720 if (delbookmark) 1721 { 1722 int days = -(gContext->GetNumSetting("DVDBookmarkDays",10)); 1723 QDateTime removedate = mythCurrentDateTime().addDays(days); 1724 query.prepare(" DELETE from dvdbookmark " 1725 " WHERE timestamp < ? "); 1726 query.addBindValue(removedate.toString(Qt::ISODate)); 1727 1728 if (!query.exec() || !query.isActive()) 1729 MythContext::DBError("GetDVDBookmark deleting old entries", query); 1730 } 1731 1732 query.prepare(" SELECT title , framenum , audionum, subtitlenum " 1733 " FROM dvdbookmark " 1734 " WHERE serialid = ? "); 1735 query.addBindValue(serialid); 1736 1737 if (query.exec() && query.isActive() && query.size() > 0) 1738 { 1739 query.next(); 1740 for (int i = 0; i < 4 ; i++) 1741 fields.append(query.value(i).toString()); 1742 } 1743 1744 return fields; 1745 } 1746 1747 void ProgramInfo::SetDVDBookmark(QStringList fields) const 1748 { 1749 1750 QStringList::Iterator it = fields.begin(); 1751 MSqlQuery query(MSqlQuery::InitCon()); 1752 1753 QString serialid = *(it); 1754 QString name = *(++it); 1755 QString title = *(++it); 1756 QString audionum = *(++it); 1757 QString subtitlenum = *(++it); 1758 QString frame = *(++it); 1759 1760 query.prepare("INSERT IGNORE INTO dvdbookmark " 1761 " ( serialid, name)" 1762 " VALUES ( :SERIALID , :NAME );"); 1763 query.bindValue(":SERIALID", serialid); 1764 query.bindValue(":NAME", name); 1765 1766 if (!query.exec() || !query.isActive()) 1767 MythContext::DBError("SetDVDBookmark inserting", query); 1768 1769 1770 query.prepare(" UPDATE dvdbookmark " 1771 " SET title = ? , " 1772 " audionum = ? , " 1773 " subtitlenum = ? , " 1774 " framenum = ? , " 1775 " timestamp = NOW() " 1776 " WHERE serialid = ? ;"); 1777 query.addBindValue(title); 1778 query.addBindValue(audionum); 1779 query.addBindValue(subtitlenum); 1780 query.addBindValue(frame); 1781 query.addBindValue(serialid); 1782 1783 if (!query.exec() || !query.isActive()) 1784 MythContext::DBError("SetDVDBookmark updating", query); 1785 } 1786 1706 1787 /** \fn ProgramInfo::IsEditing(void) const 1707 1788 * \brief Queries "recorded" table for its "editing" field 1708 1789 * and returns true if it is set to true.