MythTV master
videodecodebuffer.cpp
Go to the documentation of this file.
1// Std
2#include <chrono>
3#include <thread>
4
5// MythTV
7#include "videodecodebuffer.h"
8
10 bool Cutlist, int Size)
11 : m_player(Player), m_videoOutput(Videoout),
12 m_honorCutlist(Cutlist), m_maxFrames(Size)
13{
14}
15
17{
18 m_runThread = false;
19 m_frameWaitCond.wakeAll();
20 while (m_isRunning)
21 std::this_thread::sleep_for(50ms);
22}
23
25{
26 m_runThread = false;
27 m_frameWaitCond.wakeAll();
28 while (m_isRunning)
29 std::this_thread::sleep_for(50ms);
30}
31
33{
34 m_isRunning = true;
35 while (m_runThread)
36 {
37 QMutexLocker locker(&m_queueLock);
38
39 if (m_frameList.size() < m_maxFrames && !m_eof)
40 {
41 locker.unlock();
42
43 DecodedFrameInfo frameinfo {};
44 frameinfo.frame = nullptr;
45 frameinfo.didFF = 0;
46 frameinfo.isKey = false;
47
48 if (m_player->TranscodeGetNextFrame(frameinfo.didFF, frameinfo.isKey, m_honorCutlist))
49 {
50 frameinfo.frame = m_videoOutput->GetLastDecodedFrame();
51 locker.relock();
52 m_frameList.append(frameinfo);
53 }
54 else if (m_player->GetEof() != kEofStateNone)
55 {
56 locker.relock();
57 m_eof = true;
58 }
59 else
60 {
61 continue;
62 }
63 m_frameWaitCond.wakeAll();
64 }
65 else
66 {
67 m_frameWaitCond.wait(locker.mutex());
68 }
69 }
70 m_isRunning = false;
71}
72
74{
75 QMutexLocker locker(&m_queueLock);
76
77 if (m_frameList.isEmpty())
78 {
79 if (m_eof)
80 return nullptr;
81
82 m_frameWaitCond.wait(locker.mutex());
83 // cppcheck-suppress knownConditionTrueFalse
84 if (m_frameList.isEmpty())
85 return nullptr;
86 }
87
88 DecodedFrameInfo tfInfo = m_frameList.takeFirst();
89 locker.unlock();
90 m_frameWaitCond.wakeAll();
91 DidFF = tfInfo.didFF;
92 Key = tfInfo.isKey;
93 return tfInfo.frame;
94}
95
96/* vim: set expandtab tabstop=4 shiftwidth=4: */
97
EofState GetEof(void) const
bool TranscodeGetNextFrame(int &DidFF, bool &KeyFrame, bool HonorCutList)
virtual MythVideoFrame * GetLastDecodedFrame()
MythVideoFrame * GetFrame(int &DidFF, bool &Key)
bool const m_honorCutlist
QList< DecodedFrameInfo > m_frameList
QWaitCondition m_frameWaitCond
~VideoDecodeBuffer() override
MythVideoOutput *const m_videoOutput
bool volatile m_runThread
void run() override
MythTranscodePlayer *const m_player
VideoDecodeBuffer(MythTranscodePlayer *Player, MythVideoOutput *Videoout, bool Cutlist, int Size=5)
bool volatile m_isRunning
@ kEofStateNone
Definition: decoderbase.h:69