")"
);
- CLog::Log(LOGDEBUG, "PVR - %s - creating table 'channelsettings'", __FUNCTION__);
- m_pDS->exec(
- "CREATE TABLE channelsettings ("
- "idChannel integer primary key, "
- "iInterlaceMethod integer, "
- "iViewMode integer, "
- "fCustomZoomAmount float, "
- "fPixelRatio float, "
- "iAudioStream integer, "
- "iSubtitleStream integer,"
- "fSubtitleDelay float, "
- "bSubtitles bool, "
- "fBrightness float, "
- "fContrast float, "
- "fGamma float,"
- "fVolumeAmplification float, "
- "fAudioDelay float, "
- "bOutputToAllSpeakers bool, "
- "bCrop bool, "
- "iCropLeft integer, "
- "iCropRight integer, "
- "iCropTop integer, "
- "iCropBottom integer, "
- "fSharpness float, "
- "fNoiseReduction float, "
- "fCustomVerticalShift float, "
- "bCustomNonLinStretch bool, "
- "bPostProcess bool, "
- "iScalingMethod integer, "
- "iDeinterlaceMode integer "
- ")"
- );
-
// disable all PVR add-on when started the first time
ADDON::VECADDONS addons;
if (!CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true))
if (iVersion < 13)
m_pDS->exec("ALTER TABLE channels ADD idEpg integer;");
- if (iVersion < 14)
- m_pDS->exec("ALTER TABLE channelsettings ADD fCustomVerticalShift float;");
-
- if (iVersion < 15)
- {
- m_pDS->exec("ALTER TABLE channelsettings ADD bCustomNonLinStretch bool;");
- m_pDS->exec("ALTER TABLE channelsettings ADD bPostProcess bool;");
- m_pDS->exec("ALTER TABLE channelsettings ADD iScalingMethod integer;");
- }
- if (iVersion < 16)
- {
- /* sqlite apparently can't delete columns from an existing table, so just leave the extra column alone */
- }
- if (iVersion < 17)
- {
- m_pDS->exec("ALTER TABLE channelsettings ADD iDeinterlaceMode integer");
- m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 2 WHERE iInterlaceMethod NOT IN (0,1)"); // anything other than none: method auto => mode force
- m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 1 WHERE iInterlaceMethod = 1"); // method auto => mode auto
- m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 0, iInterlaceMethod = 1 WHERE iInterlaceMethod = 0"); // method none => mode off, method auto
- }
if (iVersion < 19)
{
// bit of a hack, but we need to keep the version/contents of the non-pvr databases the same to allow clean upgrades
if (iVersion < 24)
m_pDS->exec("ALTER TABLE channels ADD bIsUserSetName bool");
+
+ if (iVersion < 25)
+ m_pDS->exec("DROP TABLE IF EXISTS channelsettings");
}
int CPVRDatabase::GetLastChannelId(void)
return iReturn;
}
-bool CPVRDatabase::DeleteChannelSettings()
-{
- CLog::Log(LOGDEBUG, "PVR - %s - deleting all channel settings from the database", __FUNCTION__);
- return DeleteValues("channelsettings");
-}
-
-bool CPVRDatabase::DeleteChannelSettings(const CPVRChannel &channel)
-{
- bool bReturn(false);
-
- /* invalid channel */
- if (channel.ChannelID() <= 0)
- {
- CLog::Log(LOGERROR, "PVR - %s - invalid channel id: %i", __FUNCTION__, channel.ChannelID());
- return bReturn;
- }
-
- Filter filter;
- filter.AppendWhere(PrepareSQL("idChannel = %u", channel.ChannelID()));
-
- return DeleteValues("channelsettings", filter);
-}
-
-bool CPVRDatabase::GetChannelSettings(const CPVRChannel &channel, CVideoSettings &settings)
-{
- bool bReturn(false);
-
- /* invalid channel */
- if (channel.ChannelID() <= 0)
- {
- CLog::Log(LOGERROR, "PVR - %s - invalid channel id: %i", __FUNCTION__, channel.ChannelID());
- return bReturn;
- }
-
- CStdString strQuery = PrepareSQL("SELECT * FROM channelsettings WHERE idChannel = %u;", channel.ChannelID());
-
- if (ResultQuery(strQuery))
- {
- try
- {
- if (m_pDS->num_rows() > 0)
- {
- settings.m_AudioDelay = m_pDS->fv("fAudioDelay").get_asFloat();
- settings.m_AudioStream = m_pDS->fv("iAudioStream").get_asInt();
- settings.m_Brightness = m_pDS->fv("fBrightness").get_asFloat();
- settings.m_Contrast = m_pDS->fv("fContrast").get_asFloat();
- settings.m_CustomPixelRatio = m_pDS->fv("fPixelRatio").get_asFloat();
- settings.m_CustomNonLinStretch = m_pDS->fv("bCustomNonLinStretch").get_asBool();
- settings.m_NoiseReduction = m_pDS->fv("fNoiseReduction").get_asFloat();
- settings.m_PostProcess = m_pDS->fv("bPostProcess").get_asBool();
- settings.m_Sharpness = m_pDS->fv("fSharpness").get_asFloat();
- settings.m_CustomZoomAmount = m_pDS->fv("fCustomZoomAmount").get_asFloat();
- settings.m_CustomVerticalShift = m_pDS->fv("fCustomVerticalShift").get_asFloat();
- settings.m_Gamma = m_pDS->fv("fGamma").get_asFloat();
- settings.m_SubtitleDelay = m_pDS->fv("fSubtitleDelay").get_asFloat();
- settings.m_SubtitleOn = m_pDS->fv("bSubtitles").get_asBool();
- settings.m_SubtitleStream = m_pDS->fv("iSubtitleStream").get_asInt();
- settings.m_ViewMode = m_pDS->fv("iViewMode").get_asInt();
- settings.m_Crop = m_pDS->fv("bCrop").get_asBool();
- settings.m_CropLeft = m_pDS->fv("iCropLeft").get_asInt();
- settings.m_CropRight = m_pDS->fv("iCropRight").get_asInt();
- settings.m_CropTop = m_pDS->fv("iCropTop").get_asInt();
- settings.m_CropBottom = m_pDS->fv("iCropBottom").get_asInt();
- settings.m_InterlaceMethod = (EINTERLACEMETHOD)m_pDS->fv("iInterlaceMethod").get_asInt();
- settings.m_DeinterlaceMode = (EDEINTERLACEMODE)m_pDS->fv("iDeinterlaceMode").get_asInt();
- settings.m_VolumeAmplification = m_pDS->fv("fVolumeAmplification").get_asFloat();
- settings.m_OutputToAllSpeakers = m_pDS->fv("bOutputToAllSpeakers").get_asBool();
- settings.m_ScalingMethod = (ESCALINGMETHOD)m_pDS->fv("iScalingMethod").get_asInt();
-
- bReturn = true;
- }
-
- m_pDS->close();
- }
- catch(...)
- {
- CLog::Log(LOGERROR, "PVR - %s - failed to get channel settings for channel '%s'", __FUNCTION__, channel.ChannelName().c_str());
- }
- }
- else
- {
- CLog::Log(LOGERROR, "PVR - %s - query failed", __FUNCTION__);
- }
-
- return bReturn;
-}
-
-bool CPVRDatabase::PersistChannelSettings(const CPVRChannel &channel, const CVideoSettings &settings)
-{
- /* invalid channel */
- if (channel.ChannelID() <= 0)
- {
- CLog::Log(LOGERROR, "PVR - %s - invalid channel id: %i", __FUNCTION__, channel.ChannelID());
- return false;
- }
-
- CStdString strQuery = PrepareSQL(
- "REPLACE INTO channelsettings "
- "(idChannel, iInterlaceMethod, iViewMode, fCustomZoomAmount, fPixelRatio, iAudioStream, iSubtitleStream, fSubtitleDelay, "
- "bSubtitles, fBrightness, fContrast, fGamma, fVolumeAmplification, fAudioDelay, bOutputToAllSpeakers, bCrop, iCropLeft, "
- "iCropRight, iCropTop, iCropBottom, fSharpness, fNoiseReduction, fCustomVerticalShift, bCustomNonLinStretch, bPostProcess, iScalingMethod, iDeinterlaceMode) VALUES "
- "(%i, %i, %i, %f, %f, %i, %i, %f, %i, %f, %f, %f, %f, %f, %i, %i, %i, %i, %i, %i, %f, %f, %f, %i, %i, %i, %i);",
- channel.ChannelID(), settings.m_InterlaceMethod, settings.m_ViewMode, settings.m_CustomZoomAmount, settings.m_CustomPixelRatio,
- settings.m_AudioStream, settings.m_SubtitleStream, settings.m_SubtitleDelay, settings.m_SubtitleOn ? 1 :0,
- settings.m_Brightness, settings.m_Contrast, settings.m_Gamma, settings.m_VolumeAmplification, settings.m_AudioDelay,
- settings.m_OutputToAllSpeakers ? 1 : 0, settings.m_Crop ? 1 : 0, settings.m_CropLeft, settings.m_CropRight, settings.m_CropTop,
- settings.m_CropBottom, settings.m_Sharpness, settings.m_NoiseReduction, settings.m_CustomVerticalShift,
- settings.m_CustomNonLinStretch ? 1 : 0, settings.m_PostProcess ? 1 : 0, settings.m_ScalingMethod, settings.m_DeinterlaceMode);
-
- return ExecuteQuery(strQuery);
-}
-
/********** Channel group methods **********/
bool CPVRDatabase::RemoveChannelsFromGroup(const CPVRChannelGroup &group)
#include "pvr/PVRManager.h"
#include "pvr/PVRDatabase.h"
#include "guilib/GUIWindowManager.h"
-#include "settings/DisplaySettings.h"
-#include "settings/MediaSettings.h"
#include "settings/Settings.h"
#include "pvr/channels/PVRChannelGroups.h"
#include "pvr/channels/PVRChannelGroupInternal.h"
#include "pvr/timers/PVRTimers.h"
#include "cores/IPlayer.h"
-#ifdef HAS_VIDEO_PLAYBACK
-#include "cores/VideoRenderers/RenderManager.h"
-#endif
-
using namespace std;
using namespace ADDON;
using namespace PVR;
CThread("PVRClient"),
m_bChannelScanRunning(false),
m_bIsSwitchingChannels(false),
- m_bIsValidChannelSettings(false),
m_playingClientId(-EINVAL),
m_bIsPlayingLiveTV(false),
m_bIsPlayingRecording(false),
{
CSingleLock lock(m_critSection);
m_bIsSwitchingChannels = false;
- if (bSwitchSuccessful)
- m_bIsValidChannelSettings = false;
}
if (!bSwitchSuccessful)
g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
}
-void CPVRClients::SaveCurrentChannelSettings(void)
-{
- CPVRChannelPtr channel;
- {
- CSingleLock lock(m_critSection);
- if (!GetPlayingChannel(channel) || !m_bIsValidChannelSettings)
- return;
- }
-
- CPVRDatabase *database = GetPVRDatabase();
- if (!database)
- return;
-
- if (CMediaSettings::Get().GetCurrentVideoSettings() != CMediaSettings::Get().GetDefaultVideoSettings())
- {
- CLog::Log(LOGDEBUG, "PVR - %s - persisting custom channel settings for channel '%s'",
- __FUNCTION__, channel->ChannelName().c_str());
- database->PersistChannelSettings(*channel, CMediaSettings::Get().GetCurrentVideoSettings());
- }
- else
- {
- CLog::Log(LOGDEBUG, "PVR - %s - no custom channel settings for channel '%s'",
- __FUNCTION__, channel->ChannelName().c_str());
- database->DeleteChannelSettings(*channel);
- }
-}
-
-void CPVRClients::LoadCurrentChannelSettings(void)
-{
- CPVRChannelPtr channel;
- {
- CSingleLock lock(m_critSection);
- if (!GetPlayingChannel(channel))
- return;
- }
-
- CPVRDatabase *database = GetPVRDatabase();
- if (!database)
- return;
-
- if (g_application.m_pPlayer->HasPlayer())
- {
- /* store the current settings so we can compare if anything has changed */
- CVideoSettings previousSettings = CMediaSettings::Get().GetCurrentVideoSettings();
-
- /* load the persisted channel settings and set them as current */
- CVideoSettings loadedChannelSettings = CMediaSettings::Get().GetDefaultVideoSettings();
- database->GetChannelSettings(*channel, loadedChannelSettings);
- CMediaSettings::Get().GetCurrentVideoSettings() = loadedChannelSettings;
-
- /* update the view mode if it set to custom or differs from the previous mode */
- if (previousSettings.m_ViewMode != loadedChannelSettings.m_ViewMode || loadedChannelSettings.m_ViewMode == ViewModeCustom)
- g_renderManager.SetViewMode(loadedChannelSettings.m_ViewMode);
-
- /* only change the subtitle stream, if it's different */
- if (previousSettings.m_SubtitleStream != loadedChannelSettings.m_SubtitleStream)
- g_application.m_pPlayer->SetSubtitle(loadedChannelSettings.m_SubtitleStream);
-
- /* only change the audio stream if it's different */
- if (g_application.m_pPlayer->GetAudioStream() != loadedChannelSettings.m_AudioStream && loadedChannelSettings.m_AudioStream >= 0)
- g_application.m_pPlayer->SetAudioStream(loadedChannelSettings.m_AudioStream);
-
- g_application.m_pPlayer->SetAVDelay(loadedChannelSettings.m_AudioDelay);
- g_application.m_pPlayer->SetDynamicRangeCompression((long)(loadedChannelSettings.m_VolumeAmplification * 100));
- g_application.m_pPlayer->SetSubtitleVisible(loadedChannelSettings.m_SubtitleOn);
- g_application.m_pPlayer->SetSubTitleDelay(loadedChannelSettings.m_SubtitleDelay);
-
- /* settings can be saved on next channel switch */
- m_bIsValidChannelSettings = true;
- }
-}
-
bool CPVRClients::UpdateAddons(void)
{
VECADDONS addons;