xbmc
SeekHandler.h
1 /*
2  * Copyright (C) 2012-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "interfaces/IActionListener.h"
12 #include "settings/lib/ISettingCallback.h"
13 #include "threads/CriticalSection.h"
14 #include "utils/Stopwatch.h"
15 
16 #include <map>
17 #include <utility>
18 #include <vector>
19 
21 
22 enum SeekType
23 {
24  SEEK_TYPE_VIDEO = 0,
25  SEEK_TYPE_MUSIC = 1
26 };
27 
29 {
30 public:
31  CSeekHandler() = default;
32  ~CSeekHandler() override;
33 
34  static void SettingOptionsSeekStepsFiller(const std::shared_ptr<const CSetting>& setting,
35  std::vector<IntegerSettingOption>& list,
36  int& current,
37  void* data);
38 
39  void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;
40  bool OnAction(const CAction &action) override;
41 
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();
47 
48  int GetSeekSize() const;
49  bool InProgress() const;
50 
51  bool HasTimeCode() const { return m_timeCodePosition > 0; }
52  int GetTimeCodeSeconds() const;
53 
54 protected:
55  CSeekHandler(const CSeekHandler&) = delete;
56  CSeekHandler& operator=(CSeekHandler const&) = delete;
57  bool SeekTimeCode(const CAction &action);
58  void ChangeTimeCode(int remote);
59 
60 private:
61  static const int analogSeekDelay = 500;
62 
63  void SetSeekSize(double seekSize);
64  int GetSeekStepSize(SeekType type, int step);
65 
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;
79 
80  CCriticalSection m_critSection;
81 };
Definition: Stopwatch.h:14
Definition: ISettingCallback.h:16
void OnSettingChanged(const std::shared_ptr< const CSetting > &setting) override
The value of the given setting has changed.
Definition: SeekHandler.cpp:259
Definition: SettingDefinitions.h:66
class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:22
Definition: SeekHandler.h:28
Definition: IActionListener.h:13