Skip to content

Commit

Permalink
Merge pull request xbmc#6521 from mkortstiege/getvideosettings
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins4kodi committed Mar 2, 2015
2 parents eaf9cbe + 4cea422 commit d996d33
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 23 deletions.
10 changes: 5 additions & 5 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
{
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/PVRManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
25 changes: 13 additions & 12 deletions xbmc/video/VideoDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3721,28 +3721,29 @@ 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
{
// 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
int idFile = GetFileId(strFilenameAndPath);
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();
Expand Down
29 changes: 26 additions & 3 deletions xbmc/video/VideoDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,32 @@ class CVideoDatabase : public CDatabase
void DeleteSet(int idSet);
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);
/*! \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);

/**
* Erases settings for all files beginning with the specified path. Defaults
Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/VideoThumbLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit d996d33

Please sign in to comment.