2 * Copyright (C) 2005-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.
12 #include "threads/CriticalSection.h"
23 virtual ~CDataCacheCore();
24 static CDataCacheCore
& GetInstance();
26 bool HasAVInfoChanges();
27 void SignalVideoInfoChange();
28 void SignalAudioInfoChange();
29 void SignalSubtitleInfoChange();
32 void SetVideoDecoderName(std::string name
, bool isHw
);
33 std::string
GetVideoDecoderName();
34 bool IsVideoHwDecoder();
35 void SetVideoDeintMethod(std::string method
);
36 std::string
GetVideoDeintMethod();
37 void SetVideoPixelFormat(std::string pixFormat
);
38 std::string
GetVideoPixelFormat();
39 void SetVideoStereoMode(std::string mode
);
40 std::string
GetVideoStereoMode();
41 void SetVideoDimensions(int width
, int height
);
44 void SetVideoFps(float fps
);
46 void SetVideoDAR(float dar
);
50 * @brief Set if the video is interlaced in cache.
51 * @param isInterlaced Set true when the video is interlaced
53 void SetVideoInterlaced(bool isInterlaced
);
56 * @brief Check if the video is interlaced from cache
57 * @return True if interlaced, otherwise false
59 bool IsVideoInterlaced();
62 void SetAudioDecoderName(std::string name
);
63 std::string
GetAudioDecoderName();
64 void SetAudioChannels(std::string channels
);
65 std::string
GetAudioChannels();
66 void SetAudioSampleRate(int sampleRate
);
67 int GetAudioSampleRate();
68 void SetAudioBitsPerSample(int bitsPerSample
);
69 int GetAudioBitsPerSample();
74 * @brief Set the EDL edit list to cache.
75 * @param editList The vector of edits to fill.
77 void SetEditList(const std::vector
<EDL::Edit
>& editList
);
80 * @brief Get the EDL edit list in cache.
81 * @return The EDL edits or an empty vector if no edits exist.
83 const std::vector
<EDL::Edit
>& GetEditList() const;
86 * @brief Set the list of cut markers in cache.
87 * @return The list of cuts or an empty list if no cuts exist
89 void SetCuts(const std::vector
<std::chrono::milliseconds
>& cuts
);
92 * @brief Get the list of cut markers from cache.
93 * @return The list of cut markers or an empty vector if no cuts exist.
95 const std::vector
<std::chrono::milliseconds
>& GetCuts() const;
98 * @brief Set the list of scene markers in cache.
99 * @return The list of scene markers or an empty list if no scene markers exist
101 void SetSceneMarkers(const std::vector
<std::chrono::milliseconds
>& sceneMarkers
);
104 * @brief Get the list of scene markers markers from cache.
105 * @return The list of scene markers or an empty vector if no scene exist.
107 const std::vector
<std::chrono::milliseconds
>& GetSceneMarkers() const;
109 void SetChapters(const std::vector
<std::pair
<std::string
, int64_t>>& chapters
);
112 * @brief Get the chapter list in cache.
113 * @return The list of chapters or an empty vector if no chapters exist.
115 const std::vector
<std::pair
<std::string
, int64_t>>& GetChapters() const;
118 void SetRenderClockSync(bool enabled
);
119 bool IsRenderClockSync();
123 * @brief Notifies the cache core that a seek operation has finished
124 * @param offset - the seek offset
126 void SeekFinished(int64_t offset
);
128 void SetStateSeeking(bool active
);
132 * @brief Checks if a seek has been performed in the last provided seconds interval
133 * @param lastSecondInterval - the last elapsed second interval to check for a seek operation
134 * @return true if a seek was performed in the lastSecondInterval, false otherwise
136 bool HasPerformedSeek(int64_t lastSecondInterval
) const;
139 * @brief Gets the last seek offset
140 * @return the last seek offset
142 int64_t GetSeekOffSet() const;
144 void SetSpeed(float tempo
, float speed
);
147 void SetFrameAdvance(bool fa
);
148 bool IsFrameAdvance();
149 bool IsPlayerStateChanged();
150 void SetGuiRender(bool gui
);
152 void SetVideoRender(bool video
);
153 bool GetVideoRender();
154 void SetPlayTimes(time_t start
, int64_t current
, int64_t min
, int64_t max
);
155 void GetPlayTimes(time_t &start
, int64_t ¤t
, int64_t &min
, int64_t &max
);
158 * \brief Get the start time
160 * For a typical video this will be zero. For live TV, this is a reference time
161 * in units of time_t (UTC) from which time elapsed starts. Ideally this would
162 * be the start of the tv show but can be any other time as well.
164 time_t GetStartTime();
167 * \brief Get the current time of playback
169 * This is the time elapsed, in ms, since the start time.
171 int64_t GetPlayTime();
174 * \brief Get the current percentage of playback if a playback buffer is available.
176 * If there is no playback buffer, percentage will be 0.
178 float GetPlayPercentage();
181 * \brief Get the minimum time
183 * This will be zero for a typical video. With timeshift, this is the time,
184 * in ms, that the player can go back. This can be before the start time.
186 int64_t GetMinTime();
189 * \brief Get the maximum time
191 * This is the maximum time, in ms, that the player can skip forward. For a
192 * typical video, this will be the total length. For live TV without
193 * timeshift this is zero, and for live TV with timeshift this will be the
196 int64_t GetMaxTime();
199 std::atomic_bool m_hasAVInfoChanges
= false;
201 CCriticalSection m_videoPlayerSection
;
202 struct SPlayerVideoInfo
204 std::string decoderName
;
206 std::string deintMethod
;
207 std::string pixFormat
;
208 std::string stereoMode
;
216 CCriticalSection m_audioPlayerSection
;
217 struct SPlayerAudioInfo
219 std::string decoderName
;
220 std::string channels
;
225 mutable CCriticalSection m_contentSection
;
230 * @brief Set the EDL edit list in cache.
231 * @param editList the list of edits to store in cache
233 void SetEditList(const std::vector
<EDL::Edit
>& editList
) { m_editList
= editList
; }
236 * @brief Get the EDL edit list in cache.
237 * @return the list of edits in cache
239 const std::vector
<EDL::Edit
>& GetEditList() const { return m_editList
; }
242 * @brief Save the list of cut markers in cache.
243 * @param cuts the list of cut markers to store in cache
245 void SetCuts(const std::vector
<std::chrono::milliseconds
>& cuts
) { m_cuts
= cuts
; }
248 * @brief Get the list of cut markers in cache.
249 * @return the list of cut markers in cache
251 const std::vector
<std::chrono::milliseconds
>& GetCuts() const { return m_cuts
; }
254 * @brief Save the list of scene markers in cache.
255 * @param sceneMarkers the list of scene markers to store in cache
257 void SetSceneMarkers(const std::vector
<std::chrono::milliseconds
>& sceneMarkers
)
259 m_sceneMarkers
= sceneMarkers
;
263 * @brief Get the list of scene markers in cache.
264 * @return the list of scene markers in cache
266 const std::vector
<std::chrono::milliseconds
>& GetSceneMarkers() const { return m_sceneMarkers
; }
269 * @brief Save the chapter list in cache.
270 * @param chapters the list of chapters to store in cache
272 void SetChapters(const std::vector
<std::pair
<std::string
, int64_t>>& chapters
)
274 m_chapters
= chapters
;
278 * @brief Get the list of chapters in cache.
279 * @return the list of chapters in cache
281 const std::vector
<std::pair
<std::string
, int64_t>>& GetChapters() const { return m_chapters
; }
284 * @brief Reset the content cache to the original values (all empty)
291 m_sceneMarkers
.clear();
295 /*!< list of EDL edits */
296 std::vector
<EDL::Edit
> m_editList
;
297 /*!< name and position for chapters */
298 std::vector
<std::pair
<std::string
, int64_t>> m_chapters
;
299 /*!< position for EDL cuts */
300 std::vector
<std::chrono::milliseconds
> m_cuts
;
301 /*!< position for EDL scene markers */
302 std::vector
<std::chrono::milliseconds
> m_sceneMarkers
;
305 CCriticalSection m_renderSection
;
311 mutable CCriticalSection m_stateSection
;
312 bool m_playerStateChanged
= false;
315 bool m_stateSeeking
{false};
316 bool m_renderGuiLayer
{false};
317 bool m_renderVideoLayer
{false};
320 bool m_frameAdvance
{false};
321 /*! Time point of the last seek operation */
322 std::chrono::time_point
<std::chrono::system_clock
> m_lastSeekTime
{
323 std::chrono::time_point
<std::chrono::system_clock
>{}};
324 /*! Last seek offset */
325 int64_t m_lastSeekOffset
{0};