17#define LOC QString("CommFlagPlayer: ")
24 QMutexLocker locker(&
s_lock);
32 QMutexLocker locker(&
s_lock);
40 QMutexLocker locker(&
s_lock);
46 QMutexLocker locker(&
s_lock);
62 uint64_t myFramesPlayed = 0;
63 uint64_t pmap_first = 0;
64 uint64_t pmap_last = 0;
87 LOG(VB_GENERAL, LOG_ERR,
"RebuildSeekTable unable to initialize video");
94 std::chrono::milliseconds save_timeout { 1s + 1ms };
107 std::cout <<
"\r \r" << std::flush;
110 bool usingIframes =
false;
113 if (inuse_timer.
elapsed() > 2534ms)
122 if (save_timer.
elapsed() > save_timeout)
125 if (myFramesPlayed - pmap_last > 5000)
126 std::this_thread::sleep_for(200ms);
131 pmap_last = myFramesPlayed;
135 pmap_first = pmap_last + 1;
147 float elapsed = flagTime.
elapsed().count() * 0.001F;
148 auto flagFPS = (elapsed > 0.0F) ?
static_cast<int>(myFramesPlayed / elapsed) : 0;
149 auto percentage =
static_cast<int>(myFramesPlayed * 100 /
m_totalFrames);
151 (*Callback)(percentage, Opaque);
155 QString str = QString(
"\r%1%/%2fps \r").arg(percentage,3).arg(flagFPS,5);
156 std::cout << qPrintable(str) << std::flush;
158 else if (percentage % 10 == 0 && prevperc != percentage)
160 prevperc = percentage;
161 LOG(VB_COMMFLAG, LOG_INFO, QString(
"Progress %1% @ %2fps").arg(percentage,3).arg(flagFPS,5));
168 QString str = QString(
"\r%1 \r").arg(myFramesPlayed,6);
169 std::cout << qPrintable(str) << std::flush;
171 else if (myFramesPlayed % 1000 == 0)
173 LOG(VB_COMMFLAG, LOG_INFO, QString(
"Frames processed %1").arg(myFramesPlayed));
194 std::cout <<
"No I-frames found, rewinding..." << std::endl;
197 pmap_first = pmap_last = myFramesPlayed = 0;
204 std::cout <<
"\r \r" << std::flush;
236 if (FrameNumber >= 0)
246 std::this_thread::sleep_for(10ms);
247 if ((tries & 10) == 10)
248 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Waited 100ms for video frame");
virtual void SetIdrOnlyKeyframes(bool)
virtual void Reset(bool reset_video_data, bool seek_reset, bool reset_file)
bool HasPositionMap(void) const
long long GetFramesRead(void) const
void TrackTotalDuration(bool track)
uint64_t SavePositionMapDelta(long long first_frame, long long last_frame)
virtual bool DoRewind(long long desiredFrame, bool discardFrames=true)
static MThreadPool * globalInstance(void)
void start(QRunnable *runnable, const QString &debugName, int priority=0)
bool RebuildSeekTable(bool ShowPercentage=true, StatusCallback Callback=nullptr, void *Opaque=nullptr)
MythVideoFrame * GetRawVideoFrame(long long FrameNumber=-1)
Returns a specific frame from the video.
MythCommFlagPlayer(PlayerContext *Context, PlayerFlags Flags=kNoFlags)
void SaveTotalDuration(void)
MythDecoderThread * m_decoderThread
virtual void DecoderStart(bool start_paused)
static const double kInaccuracyNone
void DoJumpToFrame(uint64_t frame, double inaccuracy)
virtual int OpenFile(int Retries=4)
bool DecoderGetFrame(DecodeType decodetype, bool unsafe=false)
bool volatile m_killDecoder
void SaveTotalFrames(void)
void ClearAfterSeek(bool clearvideobuffers=true)
This is to support seeking...
void SetPlaying(bool is_playing)
PlayerContext * m_playerCtx
MythVideoOutput * m_videoOutput
EofState GetEof(void) const
virtual bool InitVideo(void)
static QWaitCondition s_wait
static QHash< DecoderBase *, uint > s_count
static uint GetCount(DecoderBase *Decoder)
static void Wait(DecoderBase *Decoder)
MythRebuildSaver(DecoderBase *Decoder, uint64_t First, uint64_t Last)
A QElapsedTimer based timer to replace use of QTime as a timer.
std::chrono::milliseconds restart(void)
Returns milliseconds elapsed since last start() or restart() and resets the count.
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
void start(void)
starts measuring elapsed time.
virtual void StartDisplayingFrame()
Tell GetLastShownFrame() to return the next frame from the head of the queue of frames to display.
virtual int ValidVideoFrames() const
Returns number of frames that are fully decoded.
virtual MythVideoFrame * GetLastShownFrame()
Returns frame from the head of the ready to be displayed queue, if StartDisplayingFrame has been call...
void LockPlayingInfo(const char *file, int line) const
void UnlockPlayingInfo(const char *file, int line) const
ProgramInfo * m_playingInfo
Currently playing info.
void UpdateInUseMark(bool force=false)
void ClearPositionMap(MarkTypes type) const
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void(*)(int, void *) StatusCallback
struct exc__state * m_last