Go to the documentation of this file.
17 #define LOC QString("PlayerUI: ")
66 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Initialising player state");
74 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unable to open video file.");
87 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unable to initialize video.");
162 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Near end, Slowing down playback.");
163 Play(1.0F,
true,
true);
197 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Near end, stopping fastforward.");
198 Play(1.0F,
true,
true);
205 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Near start, stopping rewind.");
207 Play(stretch,
true,
true);
213 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unknown recorder error, exiting decoder");
215 SetErrored(tr(
"Irrecoverable recorder error"));
248 LOG(VB_GENERAL, LOG_NOTICE,
LOC +
"LiveTV forcing JumpTo 1");
253 bool drained =
false;
273 LOG(VB_PLAYBACK, LOG_INFO,
274 QString(
"waiting for no video frames %1")
277 LOG(VB_PLAYBACK, LOG_INFO,
278 QString(
"HasReachedEof() at framesPlayed=%1 totalFrames=%2")
317 QString message =
"COMMFLAG_REQUEST ";
446 bool hasForcedTextTrack =
false;
447 uint forcedTrackNumber = 0;
451 for (
uint i = 0; !hasForcedTextTrack && i < numTextTracks; ++i)
455 hasForcedTextTrack =
true;
456 forcedTrackNumber = i;
460 if (hasForcedTextTrack)
519 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Display Refresh Rate: %1 Video Frame Rate: %2")
534 LOG(VB_PLAYBACK, LOG_DEBUG, QString(
"Clearing render one"));
550 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"FileChanged");
602 LOG(VB_PLAYBACK, LOG_DEBUG, QString(
"Clearing render one"));
609 bool showsecondfield =
false;
619 bool olddeinterlaced =
Frame->m_alreadyDeinterlaced;
621 Frame->m_alreadyDeinterlaced =
false;
627 if (!showsecondfield && secondprepare)
629 Frame->m_alreadyDeinterlaced = olddeinterlaced;
631 else if (showsecondfield)
652 SetErrored(tr(
"Serious error detected in Video Output"));
719 bool ForceUpdate,
int ReferenceFrames,
771 qint64 endtime = std::min(endactual, endsched);
772 numFrames =
static_cast<uint64_t
>((endtime - starttime) *
m_videoFrameRate);
776 auto offset = std::chrono::seconds(lround(0.14 * (numFrames /
m_videoFrameRate)));
777 offset = std::clamp(offset, 240s, 720s);
782 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Marking recording as watched using offset %1 minutes")
783 .arg(offset.count()/60));
814 return (duration_cast<floatusecs>(realfi) / 2.0) > (duration_cast<floatusecs>(
m_refreshInterval) * 0.995);
820 Map.insert(
"samplerate", samplerate);
832 Map.insert(
"videoframes", frames);
837 Map[
"framerate"] = QString(
"%1%2%3")
855 Map[
"videowidth"] = QString::number(width);
856 Map[
"videoheight"] = QString::number(height);
865 Map[
"videodescrip"] = interlaced ?
"UHD_4K_I" :
"UHD_4K_P";
866 else if (width == 1920 || height == 1080 || height == 1088)
867 Map[
"videodescrip"] = interlaced ?
"HD_1080_I" :
"HD_1080_P";
868 else if ((width == 1280 || height == 720) && !interlaced)
869 Map[
"videodescrip"] =
"HD_720_P";
870 else if (height >= 720)
871 Map[
"videodescrip"] =
"HD";
873 Map[
"videodescrip"] =
"SD";
937 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"JumpToStream - begin");
940 if (stream.isEmpty())
956 LOG(VB_GENERAL, LOG_ERR,
LOC +
"JumpToStream buffer OpenFile failed");
958 SetErrored(tr(
"Error opening remote stream buffer"));
970 LOG(VB_GENERAL, LOG_ERR,
LOC +
"JumpToStream OpenFile failed.");
972 SetErrored(tr(
"Error opening remote stream"));
983 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"JumpToStream length %1 bytes @ %2 Kbps = %3 Secs, %4 frames @ %5 fps")
1001 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"JumpToStream - end");
1009 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"SwitchToProgram - start");
1010 bool discontinuity =
false;
1011 bool newtype =
false;
1048 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"SwitchToProgram's OpenFile failed (input type: %1)")
1052 SetErrored(tr(
"Error opening switch program buffer"));
1059 discontinuity =
true;
1063 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"SwitchToProgram(void) "
1064 "discont: %1 newtype: %2 newid: %3 decoderEof: %4")
1065 .arg(discontinuity).arg(newtype).arg(newid).arg(
GetEof()));
1067 if (discontinuity || newtype)
1077 SetErrored(tr(
"Error opening switch program file"));
1095 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SwitchToProgram failed.");
1107 if (discontinuity || newtype)
1114 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"SwitchToProgram - end");
1119 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"JumpToProgram - start");
1120 bool discontinuity =
false;
1121 bool newtype =
false;
1167 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"JumpToProgram's OpenFile failed (input type: %1)")
1171 SetErrored(tr(
"Error opening jump program file buffer"));
1180 if (newtype || wasDummy)
1183 SetErrored(tr(
"Error opening jump program file"));
1190 LOG(VB_GENERAL, LOG_ERR,
LOC +
"JumpToProgram failed.");
1192 SetErrored(tr(
"Error reopening video decoder"));
1219 if (nextpos > (duration - maxpos))
1221 nextpos = duration - maxpos;
1225 else if (nextpos < 0s)
1228 nextpos += duration;
1238 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
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.
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()
virtual void InitFrameInterval()
virtual void SetLastPlayPosition(uint64_t frame=0)
@ kState_WatchingPreRecorded
Watching Pre-recorded is a TV only state for when we are watching a pre-existing recording.
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()
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.