From 6cc868304700cb7720773e7b8e16b37b4737136d Mon Sep 17 00:00:00 2001 From: Matthias Kortstiege Date: Sun, 22 Feb 2015 21:16:59 +0100 Subject: [PATCH 1/5] [videodatabase] fetch videos settings by file id, item and path --- xbmc/video/VideoDatabase.cpp | 13 +++++++++++-- xbmc/video/VideoDatabase.h | 6 ++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 5af287a5474b4..61dcf16809b06 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -3721,9 +3721,19 @@ void CVideoDatabase::GetTags(int media_id, const std::string &media_type, std::v } } +bool CVideoDatabase::GetVideoSettings(const CFileItem &item, CVideoSettings &settings) +{ + return GetVideoSettings(GetFileId(item), settings); +} + /// \brief GetVideoSettings() obtains any saved video settings for the current file. /// \retval Returns true if the settings exist, false otherwise. -bool CVideoDatabase::GetVideoSettings(const std::string &strFilenameAndPath, CVideoSettings &settings) +bool CVideoDatabase::GetVideoSettings(const std::string &filePath, CVideoSettings &settings) +{ + return GetVideoSettings(GetFileId(filePath), settings); +} + +bool CVideoDatabase::GetVideoSettings(int idFile, CVideoSettings &settings) { try { @@ -3735,7 +3745,6 @@ bool CVideoDatabase::GetVideoSettings(const std::string &strFilenameAndPath, CVi URIUtils::Split(strFilenameAndPath, strPath, strFileName); std::string strSQL=PrepareSQL("select * from settings, files, path where settings.idFile=files.idFile and path.idPath=files.idPath and path.strPath='%s' and files.strFileName='%s'", strPath.c_str() , strFileName.c_str()); #else - int idFile = GetFileId(strFilenameAndPath); if (idFile < 0) return false; if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index 8942b439f4784..0e66622fe9646 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -514,8 +514,10 @@ class CVideoDatabase : public CDatabase void DeleteTag(int idTag, VIDEODB_CONTENT_TYPE mediaType); // per-file video settings - bool GetVideoSettings(const std::string &strFilenameAndPath, CVideoSettings &settings); - void SetVideoSettings(const std::string &strFilenameAndPath, const CVideoSettings &settings); + bool GetVideoSettings(int idFile, CVideoSettings &settings); + bool GetVideoSettings(const CFileItem &item, CVideoSettings &settings); + bool GetVideoSettings(const std::string &filePath, CVideoSettings &settings); + void SetVideoSettings(const std::string &filePath, const CVideoSettings &settings); /** * Erases settings for all files beginning with the specified path. Defaults From dc13aa8b76b9708a8c465e37655e4ef39441256e Mon Sep 17 00:00:00 2001 From: Matthias Kortstiege Date: Sun, 22 Feb 2015 21:18:30 +0100 Subject: [PATCH 2/5] [videodatabase] remove dead code from GetVideoSettings --- xbmc/video/VideoDatabase.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 61dcf16809b06..1fee839ab9864 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -3737,21 +3737,13 @@ bool CVideoDatabase::GetVideoSettings(int idFile, CVideoSettings &settings) { try { - // obtain the FileID (if it exists) -#ifdef NEW_VIDEODB_METHODS - if (NULL == m_pDB.get()) return false; - if (NULL == m_pDS.get()) return false; - std::string strPath, strFileName; - URIUtils::Split(strFilenameAndPath, strPath, strFileName); - std::string strSQL=PrepareSQL("select * from settings, files, path where settings.idFile=files.idFile and path.idPath=files.idPath and path.strPath='%s' and files.strFileName='%s'", strPath.c_str() , strFileName.c_str()); -#else if (idFile < 0) return false; if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; - // ok, now obtain the settings for this file + std::string strSQL=PrepareSQL("select * from settings where settings.idFile = '%i'", idFile); -#endif m_pDS->query( strSQL.c_str() ); + if (m_pDS->num_rows() > 0) { // get the video settings info settings.m_AudioDelay = m_pDS->fv("AudioDelay").get_asFloat(); From 561fdf1cf5d596a3004c00bde5a7bdac093bd663 Mon Sep 17 00:00:00 2001 From: Matthias Kortstiege Date: Sun, 22 Feb 2015 21:20:13 +0100 Subject: [PATCH 3/5] [videodatabase] add doxy for Get-/SetVideoSettings functions --- xbmc/video/VideoDatabase.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index 0e66622fe9646..d9b25bef3c3de 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -513,10 +513,31 @@ class CVideoDatabase : public CDatabase void DeleteSet(int idSet); void DeleteTag(int idTag, VIDEODB_CONTENT_TYPE mediaType); - // per-file video settings + /*! \brief Get video settings for the specified file id + \param idFile file id to get the settings for + \return true if video settings found, false otherwise + \sa SetVideoSettings + */ bool GetVideoSettings(int idFile, CVideoSettings &settings); + + /*! \brief Get video settings for the specified file item + \param item item to get the settings for + \return true if video settings found, false otherwise + \sa SetVideoSettings + */ bool GetVideoSettings(const CFileItem &item, CVideoSettings &settings); + + /*! \brief Get video settings for the specified file path + \param filePath filepath to get the settings for + \return true if video settings found, false otherwise + \sa SetVideoSettings + */ bool GetVideoSettings(const std::string &filePath, CVideoSettings &settings); + + /*! \brief Set video settings for the specified file path + \param filePath filepath to set the settings for + \sa GetVideoSettings + */ void SetVideoSettings(const std::string &filePath, const CVideoSettings &settings); /** From b742162b2ed4e20082028266d6aad2e1ea154e6e Mon Sep 17 00:00:00 2001 From: Matthias Kortstiege Date: Sun, 22 Feb 2015 21:21:25 +0100 Subject: [PATCH 4/5] [videothumbloader] load videosettings by item instead by path --- xbmc/video/VideoThumbLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/video/VideoThumbLoader.cpp b/xbmc/video/VideoThumbLoader.cpp index 583d9d015f6ed..196846632e68b 100644 --- a/xbmc/video/VideoThumbLoader.cpp +++ b/xbmc/video/VideoThumbLoader.cpp @@ -567,7 +567,7 @@ void CVideoThumbLoader::DetectAndAddMissingItemData(CFileItem &item) // check for custom stereomode setting in video settings CVideoSettings itemVideoSettings; m_videoDatabase->Open(); - if (m_videoDatabase->GetVideoSettings(path, itemVideoSettings) && itemVideoSettings.m_StereoMode != RENDER_STEREO_MODE_OFF) + if (m_videoDatabase->GetVideoSettings(item, itemVideoSettings) && itemVideoSettings.m_StereoMode != RENDER_STEREO_MODE_OFF) stereoMode = CStereoscopicsManager::Get().ConvertGuiStereoModeToString( (RENDER_STEREO_MODE) itemVideoSettings.m_StereoMode ); m_videoDatabase->Close(); From 4cea4228ae4143d330d70ebea931cc5aeaea7db8 Mon Sep 17 00:00:00 2001 From: Matthias Kortstiege Date: Sun, 22 Feb 2015 21:23:58 +0100 Subject: [PATCH 5/5] [application] load videosettings by item --- xbmc/Application.cpp | 10 +++++----- xbmc/Application.h | 2 +- xbmc/pvr/PVRManager.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index e889146118e04..16ca2c6fd2242 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -3042,7 +3042,7 @@ PlayBackRet CApplication::PlayStack(const CFileItem& item, bool bRestart) // case 2: all other stacks else { - LoadVideoSettings(item.GetPath()); + LoadVideoSettings(item); // see if we have the info in the database // TODO: If user changes the time speed (FPS via framerate conversion stuff) @@ -3269,7 +3269,7 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart) else { options.starttime = item.m_lStartOffset / 75.0; - LoadVideoSettings(item.GetPath()); + LoadVideoSettings(item); if (item.IsVideo()) { @@ -3771,15 +3771,15 @@ void CApplication::UpdateFileState() } } -void CApplication::LoadVideoSettings(const std::string &path) +void CApplication::LoadVideoSettings(const CFileItem& item) { CVideoDatabase dbs; if (dbs.Open()) { - CLog::Log(LOGDEBUG, "Loading settings for %s", path.c_str()); + CLog::Log(LOGDEBUG, "Loading settings for %s", item.GetPath().c_str()); // Load stored settings if they exist, otherwise use default - if (!dbs.GetVideoSettings(path, CMediaSettings::Get().GetCurrentVideoSettings())) + if (!dbs.GetVideoSettings(item, CMediaSettings::Get().GetCurrentVideoSettings())) CMediaSettings::Get().GetCurrentVideoSettings() = CMediaSettings::Get().GetDefaultVideoSettings(); dbs.Close(); diff --git a/xbmc/Application.h b/xbmc/Application.h index bc4b5a874794e..1a9914c775846 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -181,7 +181,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs PlayBackRet PlayFile(const CFileItem& item, bool bRestart = false); void SaveFileState(bool bForeground = false); void UpdateFileState(); - void LoadVideoSettings(const std::string &path); + void LoadVideoSettings(const CFileItem& item); void StopPlaying(); void Restart(bool bSamePosition = true); void DelayedPlayerRestart(); diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 3bdbef12733ea..1cbdf3bd80096 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -1329,7 +1329,7 @@ bool CPVRManager::PerformChannelSwitch(const CPVRChannelPtr &channel, bool bPrev // save previous and load new channel's settings (view mode is updated in // the player) g_application.SaveFileState(); - g_application.LoadVideoSettings(channel->Path()); + g_application.LoadVideoSettings(channel); // set channel as selected item CGUIWindowPVRBase::SetSelectedItemPath(channel->IsRadio(), channel->Path());