MythTV master
mythtranscodeplayer.cpp
Go to the documentation of this file.
1// MythTV
3
5
6#define LOC QString("TranscodePlayer: ")
7
9 : MythPlayer(Context, Flags)
10{
11}
12
14{
15 // TODO this is called too early to work but the second call to DecoderBase::SetTranscoding
16 // is embedded in the middle of MythPlayer::OpenFile
17 m_transcoding = Transcoding;
18 if (m_decoder)
19 m_decoder->SetTranscoding(Transcoding);
20 else
21 LOG(VB_GENERAL, LOG_WARNING, LOC + "No decoder yet - cannot set transcoding");
22}
23
25{
26 // Are these really needed?
27 SetPlaying(true);
28 m_keyframeDist = 30;
29
30 if (!InitVideo())
31 {
32 LOG(VB_GENERAL, LOG_ERR, LOC + "Unable to initialize video for transcode.");
33 SetPlaying(false);
34 return;
35 }
36
39
40 if (m_decoder)
42}
43
45{
46 m_deleteMap.SetMap(CutList);
47}
48
49bool MythTranscodePlayer::TranscodeGetNextFrame(int &DidFF, bool &KeyFrame, bool HonorCutList)
50{
51 m_playerCtx->LockPlayingInfo(__FILE__, __LINE__);
54 m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
55
56 int64_t lastDecodedFrameNumber = m_videoOutput->GetLastDecodedFrame()->m_frameNumber;
57
58 if ((lastDecodedFrameNumber == 0) && HonorCutList)
60
61 if (!m_decoderThread)
62 DecoderStart(true/*start paused*/);
63
64 if (!m_decoder)
65 return false;
66
67 {
68 QMutexLocker decoderlocker(&m_decoderChangeLock);
70 return false;
71 }
72
73 if (GetEof() != kEofStateNone)
74 return false;
75
76 if (HonorCutList && !m_deleteMap.IsEmpty())
77 {
78 if (m_totalFrames && lastDecodedFrameNumber >= static_cast<int64_t>(m_totalFrames))
79 return false;
80
81 uint64_t jumpto = 0;
82 if (m_deleteMap.TrackerWantsToJump(static_cast<uint64_t>(lastDecodedFrameNumber), jumpto))
83 {
84 LOG(VB_GENERAL, LOG_INFO, LOC + QString("Fast-Forwarding from %1 to %2")
85 .arg(lastDecodedFrameNumber).arg(jumpto));
86 if (jumpto >= m_totalFrames)
87 {
89 return false;
90 }
91
92 // For 0.25, move this to DoJumpToFrame(jumpto)
93 WaitForSeek(jumpto, 0);
97 m_decoderChangeLock.unlock();
98 DidFF = 1;
99 }
100 }
101 if (GetEof() != kEofStateNone)
102 return false;
103 KeyFrame = m_decoder->IsLastFrameKey();
104 return true;
105}
void SetTranscoding(bool value)
Definition: decoderbase.h:214
virtual bool IsLastFrameKey(void) const =0
void SetSeekSnap(uint64_t snap)
Definition: decoderbase.h:137
void SetMap(const frm_dir_map_t &map)
Use the given map.
Definition: deletemap.cpp:720
void TrackerReset(uint64_t frame)
Resets the internal state tracker.
Definition: deletemap.cpp:811
bool TrackerWantsToJump(uint64_t frame, uint64_t &to) const
Returns true if the given frame has passed the last cut point start and provides the frame number of ...
Definition: deletemap.cpp:847
bool IsEmpty(void) const
Definition: deletemap.cpp:259
void SetEof(EofState eof)
MythDecoderThread * m_decoderThread
Definition: mythplayer.h:367
virtual void DecoderStart(bool start_paused)
void WaitForSeek(uint64_t frame, uint64_t seeksnap_wanted)
DecoderBase * m_decoder
Definition: mythplayer.h:362
DeleteMap m_deleteMap
Definition: mythplayer.h:478
QRecursiveMutex m_decoderChangeLock
Definition: mythplayer.h:363
uint64_t m_framesPlayed
Definition: mythplayer.h:424
uint64_t m_totalFrames
Definition: mythplayer.h:425
bool m_transcoding
Definition: mythplayer.h:405
bool DoGetFrame(DecodeType DecodeType)
Get one frame from the decoder.
void ClearAfterSeek(bool clearvideobuffers=true)
This is to support seeking...
void SetPlaying(bool is_playing)
Definition: mythplayer.cpp:242
PlayerContext * m_playerCtx
Definition: mythplayer.h:366
MythVideoOutput * m_videoOutput
Definition: mythplayer.h:364
EofState GetEof(void) const
virtual bool InitVideo(void)
Definition: mythplayer.cpp:270
uint m_keyframeDist
Video (input) Number of frames between key frames (often inaccurate)
Definition: mythplayer.h:445
bool TranscodeGetNextFrame(int &DidFF, bool &KeyFrame, bool HonorCutList)
void SetCutList(const frm_dir_map_t &CutList)
void SetTranscoding(bool Transcoding)
MythTranscodePlayer(PlayerContext *Context, PlayerFlags Flags=kNoFlags)
long long m_frameNumber
Definition: mythframe.h:128
virtual MythVideoFrame * GetLastDecodedFrame()
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)
@ kEofStateDelayed
Definition: decoderbase.h:70
@ kEofStateNone
Definition: decoderbase.h:69
@ kDecodeAV
Definition: decoderbase.h:52
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
PlayerFlags
Definition: mythplayer.h:65
#define LOC
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:117