Go to the documentation of this file.
19 #define LOC QString("PlayerUI: ")
25 m_display(MainWindow->GetDisplay())
69 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Initialising player state");
77 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unable to open video file.");
90 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unable to initialize video.");
165 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Near end, Slowing down playback.");
166 Play(1.0F,
true,
true);
200 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Near end, stopping fastforward.");
201 Play(1.0F,
true,
true);
208 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Near start, stopping rewind.");
210 Play(stretch,
true,
true);
216 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unknown recorder error, exiting decoder");
218 SetErrored(tr(
"Irrecoverable recorder error"));
251 LOG(VB_GENERAL, LOG_NOTICE,
LOC +
"LiveTV forcing JumpTo 1");
256 bool drained =
false;
276 LOG(VB_PLAYBACK, LOG_INFO,
277 QString(
"waiting for no video frames %1")
280 LOG(VB_PLAYBACK, LOG_INFO,
281 QString(
"HasReachedEof() at framesPlayed=%1 totalFrames=%2")
320 QString message =
"COMMFLAG_REQUEST ";
449 bool hasForcedTextTrack =
false;
450 uint forcedTrackNumber = 0;
454 for (
uint i = 0; !hasForcedTextTrack && i < numTextTracks; ++i)
458 hasForcedTextTrack =
true;
459 forcedTrackNumber = i;
463 if (hasForcedTextTrack)
522 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Display Refresh Rate: %1 Video Frame Rate: %2")
537 LOG(VB_PLAYBACK, LOG_DEBUG, QString(
"Clearing render one"));
553 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"FileChanged");
605 LOG(VB_PLAYBACK, LOG_DEBUG, QString(
"Clearing render one"));
612 bool showsecondfield =
false;
622 bool olddeinterlaced =
Frame->m_alreadyDeinterlaced;
624 Frame->m_alreadyDeinterlaced =
false;
630 if (!showsecondfield && secondprepare)
632 Frame->m_alreadyDeinterlaced = olddeinterlaced;
634 else if (showsecondfield)
655 SetErrored(tr(
"Serious error detected in Video Output"));
722 bool ForceUpdate,
int ReferenceFrames,
774 qint64 endtime = std::min(endactual, endsched);
775 numFrames =
static_cast<uint64_t
>((endtime - starttime) *
m_videoFrameRate);
779 auto offset = std::chrono::seconds(lround(0.14 * (numFrames /
m_videoFrameRate)));
785 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Marking recording as watched using offset %1 minutes")
786 .arg(offset.count()/60));
817 return (duration_cast<floatusecs>(realfi) / 2.0) > (duration_cast<floatusecs>(
m_refreshInterval) * 0.995);
823 Map.insert(
"samplerate", samplerate);
835 Map.insert(
"videoframes", frames);
840 Map[
"framerate"] = QString(
"%1%2%3")
847 QString displayfps = QString(
"%1x%2@%3Hz")
851 Map[
"displayfps"] = displayfps;
864 Map[
"videowidth"] = QString::number(width);
865 Map[
"videoheight"] = QString::number(height);
874 Map[
"videodescrip"] = interlaced ?
"UHD_4K_I" :
"UHD_4K_P";
875 else if (width == 1920 || height == 1080 || height == 1088)
876 Map[
"videodescrip"] = interlaced ?
"HD_1080_I" :
"HD_1080_P";
877 else if ((width == 1280 || height == 720) && !interlaced)
878 Map[
"videodescrip"] =
"HD_720_P";
879 else if (height >= 720)
880 Map[
"videodescrip"] =
"HD";
882 Map[
"videodescrip"] =
"SD";
946 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"JumpToStream - begin");
949 if (stream.isEmpty())
965 LOG(VB_GENERAL, LOG_ERR,
LOC +
"JumpToStream buffer OpenFile failed");
967 SetErrored(tr(
"Error opening remote stream buffer"));
979 LOG(VB_GENERAL, LOG_ERR,
LOC +
"JumpToStream OpenFile failed.");
981 SetErrored(tr(
"Error opening remote stream"));
992 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"JumpToStream length %1 bytes @ %2 Kbps = %3 Secs, %4 frames @ %5 fps")
1010 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"JumpToStream - end");
1018 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"SwitchToProgram - start");
1019 bool discontinuity =
false;
1020 bool newtype =
false;
1057 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"SwitchToProgram's OpenFile failed (input type: %1)")
1061 SetErrored(tr(
"Error opening switch program buffer"));
1068 discontinuity =
true;
1072 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"SwitchToProgram(void) "
1073 "discont: %1 newtype: %2 newid: %3 decoderEof: %4")
1074 .arg(discontinuity).arg(newtype).arg(newid).arg(
GetEof()));
1076 if (discontinuity || newtype)
1086 SetErrored(tr(
"Error opening switch program file"));
1106 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SwitchToProgram failed.");
1118 if (discontinuity || newtype)
1125 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"SwitchToProgram - end");
1130 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"JumpToProgram - start");
1131 bool discontinuity =
false;
1132 bool newtype =
false;
1178 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"JumpToProgram's OpenFile failed (input type: %1)")
1182 SetErrored(tr(
"Error opening jump program file buffer"));
1191 if (newtype || wasDummy)
1194 SetErrored(tr(
"Error opening jump program file"));
1203 LOG(VB_GENERAL, LOG_ERR,
LOC +
"JumpToProgram failed.");
1205 SetErrored(tr(
"Error reopening video decoder"));
1232 if (nextpos > (duration - maxpos))
1234 nextpos = duration - maxpos;
1238 else if (nextpos < 0s)
1241 nextpos += duration;
1251 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"JumpToProgram - end");
bool IsNearEnd(void)
Returns true iff near end of recording.
InteractiveTV * GetInteractiveTV() override
virtual void GetOSDBounds(QRect &Total, QRect &Visible, float &VisibleAspect, float &FontScaling, float ThemeAspect) const
virtual void SetBookmark(bool Clear=false)
virtual void VideoStart()
bool IsRecorderErrored(void) const
virtual void SetTrack(uint Type, uint TrackNo)
QString MakeUniqueKey(void) const
Creates a unique string that can be used to identify an existing recording.
bool Detect(MythVideoFrame *Frame, float VideoAspect, AdjustFillMode &Current)
Detects if this frame is or is not letterboxed.
TVState GetState(void) const
bool m_enableForcedSubtitles
double GetRefreshRate() const
void SendMessage(const QString &message)
void UnlockPlayingInfo(const char *file, int line) const
void InitialiseState() override
bool ImageHasChanged(void)
void JumpToNext(bool up, std::chrono::seconds pos)
jump to the next (up == true) or previous (up == false) liveTV program If pos > 0: indicate the absol...
void SetEof(EofState eof)
bool m_inJumpToProgramPause
void EnableSubtitles(int Type, bool ForcedOnly=false)
void SaveBookmark(uint64_t frame)
Clears any existing bookmark in DB and if frame is greater than 0 sets a new bookmark.
CommBreakMap m_commBreakMap
bool DoSkipCommercials(uint64_t &jumpToFrame, uint64_t framesPlayed, double video_frame_rate, uint64_t totalFrames, QString &comm_msg)
virtual bool DisplayNormalFrame(bool CheckPrebuffer=true)
bool m_checkAutoVisualise
virtual void ChangeSpeed(void)
void UpdateBookmark(bool Clear=false)
void SetNumCycles(int cycles)
void SeekingSlow(int Count)
MythPlayerAVSync m_avSync
void EnableFrameRateMonitor(bool Enable=false)
int FreeVideoFrames()
Returns number of frames available for decoding onto.
std::chrono::microseconds m_frameInterval
always adjusted for play_speed
virtual int OpenFile(int Retries=4)
virtual void EventStart()
QRect GetDisplayVisibleRect(void) const
void GetCodecDescription(InfoMap &Map)
virtual bool PrebufferEnoughFrames(int min_buffers=0)
std::chrono::seconds m_totalDuration
static constexpr const char * OSD_WIN_INTERACT
void SetPlayerChangingBuffers(bool val)
bool m_forcePositionMapSync
virtual bool HasReachedEof(void) const
MythPlayerUI(MythMainWindow *MainWindow, TV *Tv, PlayerContext *Context, PlayerFlags Flags)
virtual void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan=kScan_Ignore)=0
static bool VERBOSE_LEVEL_CHECK(uint64_t mask, LogLevel_t level)
void ResetWindow(const QString &Window)
DetectLetterbox m_detectLetterBox
virtual void PreProcessNormalFrame()
bool IsErrored(void) const
QDateTime GetScheduledEndTime(void) const
The scheduled end time of the program.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
uint64_t GetCurrentFrameCount(void) const
void SetText(const QString &Window, const InfoMap &Map, OSDTimeout Timeout)
void UpdateInUseMark(bool force=false)
virtual void SetFramesPlayed(long long FramesPlayed)
long long CalcRWTime(long long rw) const
CalcRWTime(rw): rewind rw frames back.
EofState GetEof(void) const
void EnableBitrateMonitor(bool Enable=false)
QDateTime GetRecordingEndTime(void) const
Approximate time the recording should have ended, did end, or is intended to end.
uint GetRawBitrate(void) const
Returns the estimated bitrate if the video were played at normal speed.
void SetOSDStatus(const QString &Title, OSDTimeout Timeout)
static constexpr const char * OSD_WIN_MESSAGE
bool GetWaitForChange(void) const
void Reinit(QRect videoRect, QRect dispRect, float aspect)
void SetWaitForChange(void)
void ReinitVideo(bool ForceUpdate) override
int GetOrigChannels(void) const
def scan(profile, smoonURL, gate)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
std::chrono::seconds GetJumpPos(void)
Returns the jump position in seconds and clears it.
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
void SetErrored(const QString &reason)
bool NeedsToJump(void) const
Returns true iff a switch and jump are required.
QString GetEncodingType(void) const
void DiscardVideoFrames(bool KeyFrame, bool Flushed)
Places frames in the available frames queue.
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 ...
static const double kInaccuracyNone
virtual std::chrono::milliseconds GetAudioBufferedTime(void)
report amount of audio buffered in milliseconds.
void DoDisplayVideoFrame(MythVideoFrame *Frame, std::chrono::microseconds Due)
QHash< QString, QString > InfoMap
void OSDDebugVisibilityChanged(bool Visible)
FrameScanType DetectInterlace(FrameScanType NewScan, float Rate, int VideoHeight)
AdjustFillMode GetAdjustFill(void) const
void UpdateOSDMessage(const QString &Message)
float GetLastFPS(void) const
virtual uint GetTrackCount(uint Type)
void EnableSubtitles(bool Enable)
virtual void EndFrame()=0
virtual QString GetCodecDecoderName(void) const =0
void CheckScanUpdate(MythVideoOutput *VideoOutput, std::chrono::microseconds FrameInterval)
StreamInfo GetTrackInfo(uint Type, uint TrackNo)
virtual int ValidVideoFrames() const
Returns number of frames that are fully decoded.
long long m_ffTime
If m_ffTime>0, number of frames to seek forward.
ProgramInfo * m_playingInfo
Currently playing info.
void SetPlayingInfo(const ProgramInfo &pginfo)
bool m_captionsEnabledbyDefault
This allows us to enable captions/subtitles later if the streams are not immediately available when t...
void LockPlayingInfo(const char *file, int line) const
int GetfpsMultiplier(void) const
virtual bool DoJumpChapter(int chapter)
MythVideoOutput * m_videoOutput
bool m_hasFullPositionMap
MythCaptionsOverlay m_captionsOverlay
MythMediaBuffer * m_buffer
static constexpr const char * OSD_WIN_DEBUG
void UpdateOSDPosition()
Update the OSD status/position window.
Jitterometer m_outputJmeter
ProgramInfo * GetSwitchProgram(bool &discont, bool &newtype, int &newid)
Returns the recording we should switch to.
void UpdateOSD(InteractiveScreen *osdWindow, MythPainter *osdPainter)
void SetIgnoreLastPlayPos(bool ignore)
If "ignore" is true QueryLastPlayPos() will return 0, otherwise QueryLastPlayPos() will return the la...
void GetPlaybackData(InfoMap &Map)
void LoadMap(PlayerContext *player_ctx, uint64_t framesPlayed)
void SetVideoParams(int Width, int Height, double FrameRate, float Aspect, bool ForceUpdate, int ReferenceFrames, FrameScanType Scan=kScan_Ignore, const QString &CodecName=QString()) override
void ClearAfterSeek(bool clearvideobuffers=true)
This is to support seeking...
float GetLastSD(void) const
TranscodingStatus QueryTranscodeStatus(void) const
Returns the "transcoded" field in "recorded" table.
FrameScanType GetScanForDisplay(MythVideoFrame *Frame, bool &SecondField)
std::chrono::microseconds m_refreshInterval
void SetBuffering(bool new_buffering)
virtual void ResetPlaying(bool resetframes=true)
double m_videoFrameRate
Video (input) Frame Rate (often inaccurate)
bool UpdateFFRewSkip(float ffrewScale=1.0F)
virtual QString GetRawEncodingType(void)
virtual long long GetFramesPlayed()
PlayerContext * m_playerCtx
virtual double GetFPS(void) const
void WaitForFrame(std::chrono::microseconds FrameDue)
QSize m_videoDispDim
Video (input) width & height.
virtual void DisplayPauseFrame()
void SetReadAdjust(long long adjust)
void SetCaptionsEnabled(bool Enable, bool UpdateOSD=true)
void RenderVideoFrame(MythVideoFrame *Frame, FrameScanType Scan, bool Prepare, std::chrono::microseconds Wait)
std::chrono::milliseconds m_latestVideoTimecode
bool m_disableForcedSubtitles
uint m_keyframeDist
Video (input) Number of frames between key frames (often inaccurate)
void ToggleAdjustFill(AdjustFillMode AdjustFillMode=kAdjustFill_Toggle)
Sets up letterboxing for various standard video frame and monitor dimensions, then calls MoveResize()...
int m_fpsMultiplier
used to detect changes
std::chrono::microseconds GetRefreshInterval(std::chrono::microseconds Fallback) const
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static eu8 clamp(eu8 value, eu8 low, eu8 high)
void InitialisePlayerState()
bool StreamStarted(bool bStarted=true)
void UnpauseDecoder(void)
void GetAVSyncData(InfoMap &Map) const
bool GetAllowForcedSubtitles(void) const
int GetSkipCommercials(void) const
void SetRefreshInterval(std::chrono::microseconds interval)
bool DoFastForward(uint64_t frames, double inaccuracy)
bool Init(QRect Rect, float FontAspect) override
void InitialiseState() override
virtual void ReinitVideo(bool ForceUpdate)
void DoJumpToFrame(uint64_t frame, double inaccuracy)
virtual void SetVideoParams(int w, int h, double fps, float aspect, bool ForceUpdate, int ReferenceFrames, FrameScanType=kScan_Ignore, const QString &codecName=QString())
void SetProgramInfo(const ProgramInfo &pginfo)
virtual void StartDisplayingFrame()
Tell GetLastShownFrame() to return the next frame from the head of the queue of frames to display.
CommSkipMode GetAutoCommercialSkip(void) const
void DoEnableForcedSubtitles()
@ kState_WatchingPreRecorded
Watching Pre-recorded is a TV only state for when we are watching a pre-existing recording.
virtual void InitFrameInterval()
virtual void SetLastPlayPosition(uint64_t frame=0)
QString GetInputType(int pos=-1) const
virtual long long CalcMaxFFTime(long long ff, bool setjump=true) const
CalcMaxFFTime(ffframes): forward ffframes forward.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
virtual void AutoDeint(MythVideoFrame *Frame, MythVideoOutput *VideoOutput, std::chrono::microseconds FrameInterval, bool AllowLock=true)
Check whether deinterlacing should be enabled.
AudioOutput * GetAudioOutput(void) const
Return internal AudioOutput object.
virtual void RenderFrame(MythVideoFrame *Frame, FrameScanType)=0
virtual void UpdateFramesPlayed(void)
void InitialiseScan(MythVideoOutput *VideoOutput)
std::chrono::milliseconds & DisplayTimecode()
void LoadExternalSubtitles()
Holds information on recordings and videos.
virtual void InitialSeek()
AVCodecID GetCodec(void) const
void SetScanType(FrameScanType Scan, MythVideoOutput *VideoOutput, std::chrono::microseconds FrameInterval)
bool IsReallyNearEnd(void) const
Returns true iff really near end of recording.
void CheckAspectRatio(MythVideoFrame *Frame)
bool IsWatchingInprogress(void) const
QRecursiveMutex m_osdLock
void SendMythSystemPlayEvent(const QString &msg, const ProgramInfo *pginfo)
bool NeedsToSwitch(void) const
Returns true iff a switch is required but no jump is required m_jumppos sets to INT_MAX means not set...
int GetSampleRate(void) const
bool AutoCommercialSkip(uint64_t &jumpToFrame, uint64_t framesPlayed, double video_frame_rate, uint64_t totalFrames, QString &comm_msg)
void SetIgnoreBookmark(bool ignore)
If "ignore" is true GetBookmark() will return 0, otherwise GetBookmark() will return the bookmark pos...
#define setpriority(x, y, z)
QElapsedTimer m_editUpdateTimer
QString GetPlaybackURL(bool checkMaster=false, bool forceCheckLocal=false)
Returns filename or URL to be used to play back this recording.
MythScreenType * GetWindow(const QString &Window) override
uint64_t TranslatePositionMsToFrame(std::chrono::milliseconds position, bool use_cutlist) const
void SetPlaying(bool is_playing)
InteractiveTV * m_interactiveTV
void DoDisableForcedSubtitles()
void AutoVisualise(bool HaveVideo)
Enable visualisation if possible, there is no video and user has requested.
void SaveWatched(bool watchedFlag)
Set "watched" field in recorded/videometadata to "watchedFlag".
QString GetDeinterlacerName()
bool m_forced
Subtitle and RawText.
std::chrono::seconds m_totalLength
void SetFrameInterval(FrameScanType scan, double frame_period)
void HideWindow(const QString &Window) override
QSize m_videoDim
Video (input) buffer width & height.
float GetStretchFactor(void) const
void InitFrameInterval() override
void SetWatched(bool ForceWatched=false)
Determines if the recording should be considered watched.
void SetProgram(const ProgramInfo &pginfo)
bool FlagIsSet(PlayerFlags arg)
float m_videoAspect
Video (input) Apect Ratio.
void SetIgnoreProgStart(bool ignore)
If "ignore" is true QueryProgStart() will return 0, otherwise QueryProgStart() will return the progst...
void ChangeSpeed() override
std::chrono::seconds GetLengthAtCurPos(void)
MythCaptionsState m_captionsState
QString GetLastCPUStats(void) const
void JumpToStream(const QString &stream)
FrameScanType GetScanType() const
std::chrono::microseconds AVSync(AudioPlayer *Audio, MythVideoFrame *Frame, std::chrono::microseconds FrameInterval, float PlaySpeed, bool HaveVideo, bool Force)
bool IsRecording(void) const
virtual MythVideoFrame * GetLastShownFrame()
Returns frame from the head of the ready to be displayed queue, if StartDisplayingFrame has been call...
virtual void RenderEnd()=0
bool CanSupportDoubleRate()
bool is_interlaced(FrameScanType Scan)
bool DoRewind(uint64_t frames, double inaccuracy)
static const double kInaccuracyDefault
void UpdateOSD(uint64_t frame, double frame_rate, OSD *osd)
Show and update the edit mode On Screen Display.
bool InitVideo() override
bool IsEditing(void) const
void UpdateLastPlayPosition(uint64_t frame)
virtual void UpdatePauseFrame(std::chrono::milliseconds &, FrameScanType=kScan_Progressive)
bool Play(float speed=1.0, bool normal=true, bool unpauseaudio=true)
void SaveLastPlayPos(uint64_t frame)
TODO Move to RecordingInfo.
bool volatile m_killDecoder
void SkipCommercials(int direction)
virtual void DecoderStart(bool start_paused)
virtual void DoneDisplayingFrame(MythVideoFrame *Frame)
Releases frame returned from GetLastShownFrame() onto the queue of frames ready for decoding onto.