From 51707597912a619720f14364e45fecbbf7aea4c3 Mon Sep 17 00:00:00 2001 From: montellese Date: Sat, 16 Jun 2012 23:18:10 +0200 Subject: [PATCH] videodb: add resumeTimeInSeconds and totalTimeInSeconds to the movie/episode/musicvideo view to eliminate extra queries --- xbmc/ThumbLoader.cpp | 3 ++- xbmc/video/VideoDatabase.cpp | 34 +++++++++++++++++++++++++--------- xbmc/video/VideoDatabase.h | 6 +++++- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/xbmc/ThumbLoader.cpp b/xbmc/ThumbLoader.cpp index ecb95876346fa..0bd7736244484 100644 --- a/xbmc/ThumbLoader.cpp +++ b/xbmc/ThumbLoader.cpp @@ -199,7 +199,8 @@ bool CVideoThumbLoader::LoadItem(CFileItem* pItem) m_database->Open(); // resume point - if (pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds == 0) + if (pItem->HasVideoInfoTag() && + pItem->GetVideoInfoTag()->m_resumePoint.type != CBookmark::RESUME && pItem->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds == 0) { if (m_database->GetResumePoint(*pItem->GetVideoInfoTag())) pItem->SetInvalid(); diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 401077529e75d..c5bad9df4adfc 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -349,14 +349,18 @@ void CVideoDatabase::CreateViews() " tvshow.c%02d AS strStudio," " tvshow.c%02d AS premiered," " tvshow.c%02d AS mpaa," - " tvshow.c%02d AS strShowPath " + " tvshow.c%02d AS strShowPath, " + " bookmark.timeInSeconds AS resumeTimeInSeconds, " + " bookmark.totalTimeInSeconds AS totalTimeInSeconds " "FROM episode" " JOIN files ON" " files.idFile=episode.idFile" " JOIN tvshow ON" " tvshow.idShow=episode.idShow" " JOIN path ON" - " files.idPath=path.idPath", VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_STUDIOS, VIDEODB_ID_TV_PREMIERED, VIDEODB_ID_TV_MPAA, VIDEODB_ID_TV_BASEPATH); + " files.idPath=path.idPath" + " LEFT JOIN bookmark ON" + " bookmark.idFile=episode.idFile AND bookmark.type=1", VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_STUDIOS, VIDEODB_ID_TV_PREMIERED, VIDEODB_ID_TV_MPAA, VIDEODB_ID_TV_BASEPATH); m_pDS->exec(episodeview.c_str()); CLog::Log(LOGINFO, "create tvshowview"); @@ -388,12 +392,16 @@ void CVideoDatabase::CreateViews() " path.strPath as strPath," " files.playCount as playCount," " files.lastPlayed as lastPlayed," - " files.dateAdded as dateAdded " + " files.dateAdded as dateAdded, " + " bookmark.timeInSeconds AS resumeTimeInSeconds, " + " bookmark.totalTimeInSeconds AS totalTimeInSeconds " "FROM musicvideo" " JOIN files ON" " files.idFile=musicvideo.idFile" " JOIN path ON" - " path.idPath=files.idPath"); + " path.idPath=files.idPath" + " LEFT JOIN bookmark ON" + " bookmark.idFile=musicvideo.idFile AND bookmark.type=1"); CLog::Log(LOGINFO, "create movieview"); m_pDS->exec("DROP VIEW IF EXISTS movieview"); @@ -403,12 +411,16 @@ void CVideoDatabase::CreateViews() " path.strPath AS strPath," " files.playCount AS playCount," " files.lastPlayed AS lastPlayed, " - " files.dateAdded AS dateAdded " + " files.dateAdded AS dateAdded, " + " bookmark.timeInSeconds AS resumeTimeInSeconds, " + " bookmark.totalTimeInSeconds AS totalTimeInSeconds " "FROM movie" " JOIN files ON" " files.idFile=movie.idFile" " JOIN path ON" - " path.idPath=files.idPath"); + " path.idPath=files.idPath" + " LEFT JOIN bookmark ON" + " bookmark.idFile=movie.idFile AND bookmark.type=1"); } //******************************************************************************************************************************** @@ -3029,7 +3041,6 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMovie(const dbiplus::sql_record* cons if (needsCast) { - GetResumePoint(details); GetCast("movie", "idMovie", details.m_iDbId, details.m_cast); castTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis(); @@ -3131,13 +3142,16 @@ CVideoInfoTag CVideoDatabase::GetDetailsForEpisode(const dbiplus::sql_record* co details.m_iIdShow = record->at(VIDEODB_DETAILS_EPISODE_TVSHOW_ID).get_asInt(); details.m_strShowPath = record->at(VIDEODB_DETAILS_EPISODE_TVSHOW_PATH).get_asString(); + details.m_resumePoint.timeInSeconds = record->at(VIDEODB_DETAILS_EPISODE_RESUME_TIME).get_asInt(); + details.m_resumePoint.totalTimeInSeconds = record->at(VIDEODB_DETAILS_EPISODE_TOTAL_TIME).get_asInt(); + details.m_resumePoint.type = CBookmark::RESUME; + movieTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis(); GetStreamDetails(details); if (needsCast) { - GetResumePoint(details); GetCast("episode", "idEpisode", details.m_iDbId, details.m_cast); GetCast("tvshow", "idShow", details.m_iIdShow, details.m_cast); @@ -3171,7 +3185,6 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMusicVideo(const dbiplus::sql_record* movieTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis(); GetStreamDetails(details); - GetResumePoint(details); details.m_strPictureURL.Parse(); return details; @@ -3191,6 +3204,9 @@ void CVideoDatabase::GetCommonDetails(const dbiplus::sql_record* const record, C details.m_playCount = record->at(VIDEODB_DETAILS_PLAYCOUNT).get_asInt(); details.m_lastPlayed.SetFromDBDateTime(record->at(VIDEODB_DETAILS_LASTPLAYED).get_asString()); details.m_dateAdded.SetFromDBDateTime(record->at(VIDEODB_DETAILS_DATEADDED).get_asString()); + details.m_resumePoint.timeInSeconds = record->at(VIDEODB_DETAILS_RESUME_TIME).get_asInt(); + details.m_resumePoint.totalTimeInSeconds = record->at(VIDEODB_DETAILS_TOTAL_TIME).get_asInt(); + details.m_resumePoint.type = CBookmark::RESUME; } void CVideoDatabase::GetCast(const CStdString &table, const CStdString &table_id, int type_id, vector &cast) diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index 895ff8635da5f..c4312bc476800 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -73,6 +73,8 @@ namespace VIDEO #define VIDEODB_DETAILS_PLAYCOUNT VIDEODB_MAX_COLUMNS + 4 #define VIDEODB_DETAILS_LASTPLAYED VIDEODB_MAX_COLUMNS + 5 #define VIDEODB_DETAILS_DATEADDED VIDEODB_MAX_COLUMNS + 6 +#define VIDEODB_DETAILS_RESUME_TIME VIDEODB_MAX_COLUMNS + 7 +#define VIDEODB_DETAILS_TOTAL_TIME VIDEODB_MAX_COLUMNS + 8 #define VIDEODB_DETAILS_EPISODE_TVSHOW_ID VIDEODB_MAX_COLUMNS + 2 #define VIDEODB_DETAILS_EPISODE_FILE VIDEODB_MAX_COLUMNS + 3 @@ -85,6 +87,8 @@ namespace VIDEO #define VIDEODB_DETAILS_EPISODE_TVSHOW_AIRED VIDEODB_MAX_COLUMNS + 10 #define VIDEODB_DETAILS_EPISODE_TVSHOW_MPAA VIDEODB_MAX_COLUMNS + 11 #define VIDEODB_DETAILS_EPISODE_TVSHOW_PATH VIDEODB_MAX_COLUMNS + 12 +#define VIDEODB_DETAILS_EPISODE_RESUME_TIME VIDEODB_MAX_COLUMNS + 13 +#define VIDEODB_DETAILS_EPISODE_TOTAL_TIME VIDEODB_MAX_COLUMNS + 14 #define VIDEODB_DETAILS_TVSHOW_PATH VIDEODB_MAX_COLUMNS + 1 #define VIDEODB_DETAILS_TVSHOW_DATEADDED VIDEODB_MAX_COLUMNS + 2 @@ -794,7 +798,7 @@ class CVideoDatabase : public CDatabase */ bool LookupByFolders(const CStdString &path, bool shows = false); - virtual int GetMinVersion() const { return 64; }; + virtual int GetMinVersion() const { return 65; }; virtual int GetExportVersion() const { return 1; }; const char *GetBaseDBName() const { return "MyVideos"; };