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 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
9 #include <QMutex>
10 #else
11 #include <QRecursiveMutex>
12 #endif
13 #include <QMap>
14 #include <QCoreApplication>
15 
16 // MythTV headers
17 #include "libmythbase/compat.h"
19 #include "libmythtv/tv.h"
21 
23 {
24  Q_DECLARE_TR_FUNCTIONS(CommBreakMap)
25 
26  public:
27  CommBreakMap(void);
28 
29  bool HasMap(void) const { return m_hascommbreaktable; }
30 
32  void SetAutoCommercialSkip(CommSkipMode autoskip, uint64_t framesPlayed);
33 
34  int GetSkipCommercials(void) const { return m_skipcommercials; }
35  void SkipCommercials(int direction);
36 
37  void ResetLastSkip(void);
38  void SetTracker(uint64_t framesPlayed);
39  void GetMap(frm_dir_map_t &map) const;
40  void SetMap(const frm_dir_map_t &newMap, uint64_t framesPlayed);
41  void LoadMap(PlayerContext *player_ctx, uint64_t framesPlayed);
42 
43  bool IsInCommBreak(uint64_t frameNumber) const;
44  bool AutoCommercialSkip(uint64_t &jumpToFrame, uint64_t framesPlayed,
45  double video_frame_rate, uint64_t totalFrames,
46  QString &comm_msg);
47  bool DoSkipCommercials(uint64_t &jumpToFrame, uint64_t framesPlayed,
48  double video_frame_rate, uint64_t totalFrames,
49  QString &comm_msg);
50 
51  private:
52  void MergeShortCommercials(double video_frame_rate);
53 
54 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
55  mutable QMutex m_commBreakMapLock {QMutex::Recursive};
56 #else
57  mutable QRecursiveMutex m_commBreakMapLock;
58 #endif
61  std::chrono::seconds m_commrewindamount {0s};
62  std::chrono::seconds m_commnotifyamount {0s};
64  time_t m_lastCommSkipTime {0/*1970*/};
65  uint64_t m_lastCommSkipStart {0};
66  time_t m_lastSkipTime {0 /*1970*/};
67  bool m_hascommbreaktable {false};
69  std::chrono::seconds m_maxskip {1h};
70  std::chrono::seconds m_maxShortMerge {0s};
72  frm_dir_map_t::Iterator m_commBreakIter;
73 };
74 
75 #endif // BREAKMAP_H
CommBreakMap::m_skipcommercials
int m_skipcommercials
Definition: commbreakmap.h:59
CommSkipMode
CommSkipMode
Definition: tv.h:130
CommBreakMap::m_lastSkipTime
time_t m_lastSkipTime
Definition: commbreakmap.h:66
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:249
CommBreakMap::SetTracker
void SetTracker(uint64_t framesPlayed)
Definition: commbreakmap.cpp:67
CommBreakMap::MergeShortCommercials
void MergeShortCommercials(double video_frame_rate)
Definition: commbreakmap.cpp:361
frm_dir_map_t
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:119
CommBreakMap::m_autocommercialskip
CommSkipMode m_autocommercialskip
Definition: commbreakmap.h:60
CommBreakMap::GetMap
void GetMap(frm_dir_map_t &map) const
Definition: commbreakmap.cpp:91
CommBreakMap::m_commnotifyamount
std::chrono::seconds m_commnotifyamount
Definition: commbreakmap.h:62
CommBreakMap::SetMap
void SetMap(const frm_dir_map_t &newMap, uint64_t framesPlayed)
Definition: commbreakmap.cpp:131
CommBreakMap::m_commBreakMapLock
QRecursiveMutex m_commBreakMapLock
Definition: commbreakmap.h:57
programtypes.h
CommBreakMap::m_lastCommSkipStart
uint64_t m_lastCommSkipStart
Definition: commbreakmap.h:65
CommBreakMap::ResetLastSkip
void ResetLastSkip(void)
Definition: commbreakmap.cpp:27
CommBreakMap::m_commBreakIter
frm_dir_map_t::Iterator m_commBreakIter
Definition: commbreakmap.h:72
CommBreakMap::SetAutoCommercialSkip
void SetAutoCommercialSkip(CommSkipMode autoskip, uint64_t framesPlayed)
Definition: commbreakmap.cpp:32
compat.h
CommBreakMap::LoadMap
void LoadMap(PlayerContext *player_ctx, uint64_t framesPlayed)
Definition: commbreakmap.cpp:50
CommBreakMap::m_lastIgnoredManualSkip
QDateTime m_lastIgnoredManualSkip
Definition: commbreakmap.h:68
CommBreakMap::IsInCommBreak
bool IsInCommBreak(uint64_t frameNumber) const
Definition: commbreakmap.cpp:98
CommBreakMap::GetSkipCommercials
int GetSkipCommercials(void) const
Definition: commbreakmap.h:34
CommBreakMap::m_lastCommSkipDirection
int m_lastCommSkipDirection
Definition: commbreakmap.h:63
CommBreakMap::m_lastCommSkipTime
time_t m_lastCommSkipTime
Definition: commbreakmap.h:64
CommBreakMap::m_maxShortMerge
std::chrono::seconds m_maxShortMerge
Definition: commbreakmap.h:70
CommBreakMap::GetAutoCommercialSkip
CommSkipMode GetAutoCommercialSkip(void) const
Definition: commbreakmap.cpp:21
CommBreakMap::m_maxskip
std::chrono::seconds m_maxskip
Definition: commbreakmap.h:69
CommBreakMap
Definition: commbreakmap.h:22
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:144
CommBreakMap::m_commBreakMap
frm_dir_map_t m_commBreakMap
Definition: commbreakmap.h:71
CommBreakMap::CommBreakMap
CommBreakMap(void)
Definition: commbreakmap.cpp:10
PlayerContext
Definition: playercontext.h:53
CommBreakMap::m_hascommbreaktable
bool m_hascommbreaktable
Definition: commbreakmap.h:67
kCommSkipOff
@ kCommSkipOff
Definition: tv.h:132
CommBreakMap::HasMap
bool HasMap(void) const
Definition: commbreakmap.h:29
CommBreakMap::m_commrewindamount
std::chrono::seconds m_commrewindamount
Definition: commbreakmap.h:61
CommBreakMap::SkipCommercials
void SkipCommercials(int direction)
Definition: commbreakmap.cpp:41