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