Merge pull request #24470 from fuzzard/release_20.3
[xbmc.git] / xbmc / settings / MediaSettings.h
blobd23923496d4ad9d16cea50ae4d4cb47f4ca225fe
1 /*
2 * Copyright (C) 2013-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "cores/VideoSettings.h"
12 #include "settings/GameSettings.h"
13 #include "settings/ISubSettings.h"
14 #include "settings/LibExportSettings.h"
15 #include "settings/lib/ISettingCallback.h"
16 #include "settings/lib/ISettingsHandler.h"
17 #include "threads/CriticalSection.h"
19 #include <map>
20 #include <string>
22 #define VOLUME_DRC_MINIMUM 0 // 0dB
23 #define VOLUME_DRC_MAXIMUM 6000 // 60dB
25 class TiXmlNode;
27 // Step used to increase/decrease audio delay
28 static constexpr float AUDIO_DELAY_STEP = 0.025f;
30 typedef enum {
31 WatchedModeAll = 0,
32 WatchedModeUnwatched,
33 WatchedModeWatched
34 } WatchedMode;
36 class CMediaSettings : public ISettingCallback, public ISettingsHandler, public ISubSettings
38 public:
39 static CMediaSettings& GetInstance();
41 bool Load(const TiXmlNode *settings) override;
42 bool Save(TiXmlNode *settings) const override;
44 void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override;
45 void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;
47 const CVideoSettings& GetDefaultVideoSettings() const { return m_defaultVideoSettings; }
48 CVideoSettings& GetDefaultVideoSettings() { return m_defaultVideoSettings; }
50 const CGameSettings& GetDefaultGameSettings() const { return m_defaultGameSettings; }
51 CGameSettings& GetDefaultGameSettings() { return m_defaultGameSettings; }
52 const CGameSettings& GetCurrentGameSettings() const { return m_currentGameSettings; }
53 CGameSettings& GetCurrentGameSettings() { return m_currentGameSettings; }
55 /*! \brief Retrieve the watched mode for the given content type
56 \param content Current content type
57 \return the current watch mode for this content type, WATCH_MODE_ALL if the content type is unknown.
58 \sa SetWatchMode
60 int GetWatchedMode(const std::string &content) const;
62 /*! \brief Set the watched mode for the given content type
63 \param content Current content type
64 \param value Watched mode to set
65 \sa GetWatchMode
67 void SetWatchedMode(const std::string &content, WatchedMode mode);
69 /*! \brief Cycle the watched mode for the given content type
70 \param content Current content type
71 \sa GetWatchMode, SetWatchMode
73 void CycleWatchedMode(const std::string &content);
75 void SetMusicPlaylistRepeat(bool repeats) { m_musicPlaylistRepeat = repeats; }
76 void SetMusicPlaylistShuffled(bool shuffled) { m_musicPlaylistShuffle = shuffled; }
78 void SetVideoPlaylistRepeat(bool repeats) { m_videoPlaylistRepeat = repeats; }
79 void SetVideoPlaylistShuffled(bool shuffled) { m_videoPlaylistShuffle = shuffled; }
81 bool DoesMediaStartWindowed() const { return m_mediaStartWindowed; }
82 void SetMediaStartWindowed(bool windowed) { m_mediaStartWindowed = windowed; }
83 int GetAdditionalSubtitleDirectoryChecked() const { return m_additionalSubtitleDirectoryChecked; }
84 void SetAdditionalSubtitleDirectoryChecked(int checked) { m_additionalSubtitleDirectoryChecked = checked; }
86 int GetMusicNeedsUpdate() const { return m_musicNeedsUpdate; }
87 void SetMusicNeedsUpdate(int version) { m_musicNeedsUpdate = version; }
88 int GetVideoNeedsUpdate() const { return m_videoNeedsUpdate; }
89 void SetVideoNeedsUpdate(int version) { m_videoNeedsUpdate = version; }
91 protected:
92 CMediaSettings();
93 CMediaSettings(const CMediaSettings&) = delete;
94 CMediaSettings& operator=(CMediaSettings const&) = delete;
95 ~CMediaSettings() override;
97 static std::string GetWatchedContent(const std::string &content);
99 private:
100 CVideoSettings m_defaultVideoSettings;
102 CGameSettings m_defaultGameSettings;
103 CGameSettings m_currentGameSettings;
105 typedef std::map<std::string, WatchedMode> WatchedModes;
106 WatchedModes m_watchedModes;
108 bool m_musicPlaylistRepeat;
109 bool m_musicPlaylistShuffle;
110 bool m_videoPlaylistRepeat;
111 bool m_videoPlaylistShuffle;
113 bool m_mediaStartWindowed;
114 int m_additionalSubtitleDirectoryChecked;
116 int m_musicNeedsUpdate; ///< if a database update means an update is required (set to the version number of the db)
117 int m_videoNeedsUpdate; ///< if a database update means an update is required (set to the version number of the db)
119 mutable CCriticalSection m_critical;