Merge pull request #25922 from sarbes/shader-cleanup
[xbmc.git] / xbmc / SeekHandler.h
blob082cc10023c3a38e735c76236f37b9949eab4985
1 /*
2 * Copyright (C) 2012-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 "input/actions/interfaces/IActionListener.h"
12 #include "settings/lib/ISettingCallback.h"
13 #include "threads/CriticalSection.h"
14 #include "utils/Stopwatch.h"
16 #include <map>
17 #include <utility>
18 #include <vector>
20 struct IntegerSettingOption;
22 enum SeekType
24 SEEK_TYPE_VIDEO = 0,
25 SEEK_TYPE_MUSIC = 1
28 class CSeekHandler : public ISettingCallback, public KODI::ACTION::IActionListener
30 public:
31 CSeekHandler() = default;
32 ~CSeekHandler() override;
34 static void SettingOptionsSeekStepsFiller(const std::shared_ptr<const CSetting>& setting,
35 std::vector<IntegerSettingOption>& list,
36 int& current,
37 void* data);
39 void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;
40 bool OnAction(const CAction &action) override;
42 void Seek(bool forward, float amount, float duration = 0, bool analogSeek = false, SeekType type = SEEK_TYPE_VIDEO);
43 void SeekSeconds(int seconds);
44 void FrameMove();
45 void Reset();
46 void Configure();
48 int GetSeekSize() const;
49 bool InProgress() const;
51 bool HasTimeCode() const { return m_timeCodePosition > 0; }
52 int GetTimeCodeSeconds() const;
54 protected:
55 CSeekHandler(const CSeekHandler&) = delete;
56 CSeekHandler& operator=(CSeekHandler const&) = delete;
57 bool SeekTimeCode(const CAction &action);
58 void ChangeTimeCode(int remote);
60 private:
61 static const int analogSeekDelay = 500;
63 void SetSeekSize(double seekSize);
64 int GetSeekStepSize(SeekType type, int step);
66 int m_seekDelay = 500;
67 std::map<SeekType, int > m_seekDelays;
68 bool m_requireSeek = false;
69 bool m_seekChanged = false;
70 bool m_analogSeek = false;
71 double m_seekSize = 0;
72 int m_seekStep = 0;
73 std::map<SeekType, std::vector<int> > m_forwardSeekSteps;
74 std::map<SeekType, std::vector<int> > m_backwardSeekSteps;
75 CStopWatch m_timer;
76 CStopWatch m_timerTimeCode;
77 int m_timeCodeStamp[6];
78 int m_timeCodePosition;
80 CCriticalSection m_critSection;