MythTV  master
commbreakmap.h
Go to the documentation of this file.
1 #ifndef BREAKMAP_H
2 #define BREAKMAP_H
3 
4 #include <cstdint>
5 
6 // Qt headers
7 #include <QtGlobal>
8 #include <QRecursiveMutex>
9 #include <QMap>
10 #include <QCoreApplication>
11 
12 // MythTV headers
13 #include "libmythbase/mythchrono.h"
15 #include "libmythtv/tv.h"
17 
19 {
20  Q_DECLARE_TR_FUNCTIONS(CommBreakMap)
21 
22  public:
23  CommBreakMap(void);
24 
25  bool HasMap(void) const { return m_hascommbreaktable; }
26 
28  void SetAutoCommercialSkip(CommSkipMode autoskip, uint64_t framesPlayed);
29 
30  int GetSkipCommercials(void) const { return m_skipcommercials; }
31  void SkipCommercials(int direction);
32 
33  void ResetLastSkip(void);
34  void SetTracker(uint64_t framesPlayed);
35  void GetMap(frm_dir_map_t &map) const;
36  void SetMap(const frm_dir_map_t &newMap, uint64_t framesPlayed);
37  void LoadMap(PlayerContext *player_ctx, uint64_t framesPlayed);
38 
39  bool IsInCommBreak(uint64_t frameNumber) const;
40  bool AutoCommercialSkip(uint64_t &jumpToFrame, uint64_t framesPlayed,
41  double video_frame_rate, uint64_t totalFrames,
42  QString &comm_msg);
43  bool DoSkipCommercials(uint64_t &jumpToFrame, uint64_t framesPlayed,
44  double video_frame_rate, uint64_t totalFrames,
45  QString &comm_msg);
46 
47  private:
48  void MergeShortCommercials(double video_frame_rate);
49 
50  mutable QRecursiveMutex m_commBreakMapLock;
53  std::chrono::seconds m_commrewindamount {0s};
54  std::chrono::seconds m_commnotifyamount {0s};
60  static constexpr std::chrono::seconds kSkipBackWindow {5s};
61  uint64_t m_lastCommSkipStart {0};
67  static constexpr std::chrono::seconds kAutoSkipDeadZone {3s};
68  bool m_hascommbreaktable {false};
70  std::chrono::seconds m_maxskip {1h};
71  std::chrono::seconds m_maxShortMerge {0s};
73  frm_dir_map_t::Iterator m_commBreakIter;
74 };
75 
76 #endif // BREAKMAP_H
CommBreakMap::m_skipcommercials
int m_skipcommercials
Definition: commbreakmap.h:51
tv.h
CommBreakMap::DoSkipCommercials
bool DoSkipCommercials(uint64_t &jumpToFrame, uint64_t framesPlayed, double video_frame_rate, uint64_t totalFrames, QString &comm_msg)
Definition: commbreakmap.cpp:250
SystemTime
std::chrono::time_point< SystemClock > SystemTime
Definition: mythchrono.h:67
CommBreakMap::SetTracker
void SetTracker(uint64_t framesPlayed)
Definition: commbreakmap.cpp:68
CommBreakMap::MergeShortCommercials
void MergeShortCommercials(double video_frame_rate)
Definition: commbreakmap.cpp:362
frm_dir_map_t
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:117
CommBreakMap::m_autocommercialskip
CommSkipMode m_autocommercialskip
Definition: commbreakmap.h:52
CommBreakMap::GetMap
void GetMap(frm_dir_map_t &map) const
Definition: commbreakmap.cpp:92
CommSkipMode
CommSkipMode
Definition: tv.h:133
CommBreakMap::m_commnotifyamount
std::chrono::seconds m_commnotifyamount
Definition: commbreakmap.h:54
CommBreakMap::SetMap
void SetMap(const frm_dir_map_t &newMap, uint64_t framesPlayed)
Definition: commbreakmap.cpp:132
CommBreakMap::m_commBreakMapLock
QRecursiveMutex m_commBreakMapLock
Definition: commbreakmap.h:50
kCommSkipOff
@ kCommSkipOff
Definition: tv.h:135
CommBreakMap::m_lastCommSkipTime
SystemTime m_lastCommSkipTime
Definition: commbreakmap.h:56
programtypes.h
CommBreakMap::m_lastSkipTime
SystemTime m_lastSkipTime
This is separate from m_lastCommSkipTime so a manual seek does not trigger the kSkipBackWindow code.
Definition: commbreakmap.h:65
CommBreakMap::m_lastCommSkipStart
uint64_t m_lastCommSkipStart
Definition: commbreakmap.h:61
CommBreakMap::ResetLastSkip
void ResetLastSkip(void)
Definition: commbreakmap.cpp:28
CommBreakMap::m_commBreakIter
frm_dir_map_t::Iterator m_commBreakIter
Definition: commbreakmap.h:73
CommBreakMap::SetAutoCommercialSkip
void SetAutoCommercialSkip(CommSkipMode autoskip, uint64_t framesPlayed)
Definition: commbreakmap.cpp:33
CommBreakMap::LoadMap
void LoadMap(PlayerContext *player_ctx, uint64_t framesPlayed)
Definition: commbreakmap.cpp:51
CommBreakMap::m_lastIgnoredManualSkip
QDateTime m_lastIgnoredManualSkip
Definition: commbreakmap.h:69
CommBreakMap::kSkipBackWindow
static constexpr std::chrono::seconds kSkipBackWindow
Time after a commercial skip that skipping back will skip to the start of the just skipped commercial...
Definition: commbreakmap.h:60
CommBreakMap::IsInCommBreak
bool IsInCommBreak(uint64_t frameNumber) const
Definition: commbreakmap.cpp:99
CommBreakMap::GetSkipCommercials
int GetSkipCommercials(void) const
Definition: commbreakmap.h:30
CommBreakMap::m_lastCommSkipDirection
int m_lastCommSkipDirection
Definition: commbreakmap.h:55
CommBreakMap::m_maxShortMerge
std::chrono::seconds m_maxShortMerge
Definition: commbreakmap.h:71
CommBreakMap::GetAutoCommercialSkip
CommSkipMode GetAutoCommercialSkip(void) const
Definition: commbreakmap.cpp:22
CommBreakMap::m_maxskip
std::chrono::seconds m_maxskip
Definition: commbreakmap.h:70
CommBreakMap
Definition: commbreakmap.h:18
playercontext.h
CommBreakMap::AutoCommercialSkip
bool AutoCommercialSkip(uint64_t &jumpToFrame, uint64_t framesPlayed, double video_frame_rate, uint64_t totalFrames, QString &comm_msg)
Definition: commbreakmap.cpp:145
CommBreakMap::m_commBreakMap
frm_dir_map_t m_commBreakMap
Definition: commbreakmap.h:72
CommBreakMap::CommBreakMap
CommBreakMap(void)
Definition: commbreakmap.cpp:11
mythchrono.h
PlayerContext
Definition: playercontext.h:49
CommBreakMap::m_hascommbreaktable
bool m_hascommbreaktable
Definition: commbreakmap.h:68
CommBreakMap::kAutoSkipDeadZone
static constexpr std::chrono::seconds kAutoSkipDeadZone
Time after any seek that an automatic commercial skip will not occur.
Definition: commbreakmap.h:67
CommBreakMap::HasMap
bool HasMap(void) const
Definition: commbreakmap.h:25
CommBreakMap::m_commrewindamount
std::chrono::seconds m_commrewindamount
Definition: commbreakmap.h:53
CommBreakMap::SkipCommercials
void SkipCommercials(int direction)
Definition: commbreakmap.cpp:42