9#define LOC QString("CommBreakMap: ")
13 m_commrewindamount(
gCoreContext->GetDurSetting<
std::chrono::seconds>(
"CommRewindAmount",0s)),
14 m_commnotifyamount(
gCoreContext->GetDurSetting<
std::chrono::seconds>(
"CommNotifyAmount",0s)),
16 m_maxskip(
gCoreContext->GetDurSetting<
std::chrono::seconds>(
"MaximumCommercialSkip", 1h)),
17 m_maxShortMerge(
gCoreContext->GetDurSetting<
std::chrono::seconds>(
"MergeShortCommBreaks", 0s)),
18 m_commBreakIter(m_commBreakMap.end())
85 LOG(VB_COMMFLAG, LOG_INFO,
LOC +
86 QString(
"new commBreakIter = %1 @ frame %2, framesPlayed = %3")
105 frm_dir_map_t::const_iterator it =
m_commBreakMap.find(frameNumber);
112 if (it.key() > frameNumber)
135 LOG(VB_COMMFLAG, LOG_INFO,
LOC +
136 QString(
"Setting New Commercial Break List, old size %1, new %2")
146 uint64_t framesPlayed,
147 double video_frame_rate,
148 uint64_t totalFrames,
181 LOG(VB_COMMFLAG, LOG_INFO,
LOC +
182 QString(
"AutoCommercialSkip(), current framesPlayed %1, commBreakIter "
183 "frame %2, incrementing commBreakIter")
192 LOG(VB_COMMFLAG, LOG_INFO,
LOC +
"AutoCommercialSkip(), at end of "
193 "commercial break list, will not skip.");
199 LOG(VB_COMMFLAG, LOG_INFO,
LOC +
"AutoCommercialSkip(), new "
200 "commBreakIter mark is another start, "
208 LOG(VB_COMMFLAG, LOG_INFO,
LOC +
"AutoCommercialSkip(), skipping would "
209 "take us to the end of the file, will "
214 LOG(VB_COMMFLAG, LOG_INFO,
LOC +
215 QString(
"AutoCommercialSkip(), new commBreakIter frame %1")
218 auto skipped_seconds = std::chrono::seconds((
int)((
m_commBreakIter.key() -
219 framesPlayed) / video_frame_rate));
224 comm_msg = tr(
"Skip %1").arg(skipTime);
229 comm_msg = tr(
"Commercial: %1").arg(skipTime);
235 LOG(VB_COMMFLAG, LOG_INFO,
LOC +
236 QString(
"AutoCommercialSkip(), auto-skipping to frame %1")
251 uint64_t framesPlayed,
252 double video_frame_rate,
253 uint64_t totalFrames, QString &comm_msg)
259 comm_msg = tr(
"Skipping Back.");
277 comm_msg = tr(
"Start of program.");
284 (((totalFrames) != 0U) &&
287 comm_msg = tr(
"At End, cannot Skip.");
296 (int64_t)framesPlayed) / video_frame_rate);
299 if (skipped_seconds > -3)
303 comm_msg = tr(
"Start of program.");
313 auto skipped_seconds = std::chrono::seconds((
int)(framediff / video_frame_rate));
326 (((totalFrames) != 0U) &&
330 comm_msg = tr(
"At End, cannot Skip.");
339 auto skipped_seconds = std::chrono::seconds((
int)(framediff / video_frame_rate));
346 comm_msg = tr(
"Too Far %1").arg(skipTime);
352 comm_msg = tr(
"Skip %1").arg(skipTime);
358 jumpToFrame = jumpto;
frm_dir_map_t m_commBreakMap
std::chrono::seconds m_maxShortMerge
QRecursiveMutex m_commBreakMapLock
CommSkipMode GetAutoCommercialSkip(void) const
bool IsInCommBreak(uint64_t frameNumber) const
SystemTime m_lastSkipTime
This is separate from m_lastCommSkipTime so a manual seek does not trigger the kSkipBackWindow code.
SystemTime m_lastCommSkipTime
int m_lastCommSkipDirection
QDateTime m_lastIgnoredManualSkip
bool DoSkipCommercials(uint64_t &jumpToFrame, uint64_t framesPlayed, double video_frame_rate, uint64_t totalFrames, QString &comm_msg)
void SetMap(const frm_dir_map_t &newMap, uint64_t framesPlayed)
void SetTracker(uint64_t framesPlayed)
void LoadMap(PlayerContext *player_ctx, uint64_t framesPlayed)
void MergeShortCommercials(double video_frame_rate)
std::chrono::seconds m_commnotifyamount
std::chrono::seconds m_commrewindamount
static constexpr std::chrono::seconds kSkipBackWindow
Time after a commercial skip that skipping back will skip to the start of the just skipped commercial...
uint64_t m_lastCommSkipStart
bool AutoCommercialSkip(uint64_t &jumpToFrame, uint64_t framesPlayed, double video_frame_rate, uint64_t totalFrames, QString &comm_msg)
void SetAutoCommercialSkip(CommSkipMode autoskip, uint64_t framesPlayed)
static constexpr std::chrono::seconds kAutoSkipDeadZone
Time after any seek that an automatic commercial skip will not occur.
CommSkipMode m_autocommercialskip
frm_dir_map_t::Iterator m_commBreakIter
std::chrono::seconds m_maxskip
void GetMap(frm_dir_map_t &map) const
void SkipCommercials(int direction)
void LockPlayingInfo(const char *file, int line) const
void UnlockPlayingInfo(const char *file, int line) const
ProgramInfo * m_playingInfo
Currently playing info.
void QueryCommBreakList(frm_dir_map_t &frames) const
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QString formatTime(std::chrono::milliseconds msecs, QString fmt)
Format a milliseconds time value.
std::chrono::seconds secsInPast(const QDateTime &past)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.