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");
virtual std::chrono::milliseconds GetAudioBufferedTime(void)
report amount of audio buffered in milliseconds.
AudioOutput * GetAudioOutput(void) const
Return internal AudioOutput object.
float GetStretchFactor(void) const
int GetSampleRate(void) const
int GetOrigChannels(void) const
AVCodecID GetCodec(void) const
CommSkipMode GetAutoCommercialSkip(void) const
bool DoSkipCommercials(uint64_t &jumpToFrame, uint64_t framesPlayed, double video_frame_rate, uint64_t totalFrames, QString &comm_msg)
void LoadMap(PlayerContext *player_ctx, uint64_t framesPlayed)
bool AutoCommercialSkip(uint64_t &jumpToFrame, uint64_t framesPlayed, double video_frame_rate, uint64_t totalFrames, QString &comm_msg)
int GetSkipCommercials(void) const
void SkipCommercials(int direction)
virtual QString GetRawEncodingType(void)
virtual uint GetTrackCount(uint Type)
void SetProgramInfo(const ProgramInfo &pginfo)
virtual QString GetCodecDecoderName(void) const =0
virtual void UpdateFramesPlayed(void)
void SetReadAdjust(long long adjust)
uint GetRawBitrate(void) const
Returns the estimated bitrate if the video were played at normal speed.
void SetWaitForChange(void)
bool GetWaitForChange(void) const
int GetfpsMultiplier(void) const
StreamInfo GetTrackInfo(uint Type, uint TrackNo)
virtual double GetFPS(void) const
void UpdateOSD(uint64_t frame, double frame_rate, OSD *osd)
Show and update the edit mode On Screen Display.
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 ...
bool IsEditing(void) const
bool Detect(MythVideoFrame *Frame, float VideoAspect, AdjustFillMode &Current)
Detects if this frame is or is not letterboxed.
void SetNumCycles(int cycles)
QString GetLastCPUStats(void) const
float GetLastFPS(void) const
float GetLastSD(void) const
std::chrono::seconds GetJumpPos(void)
Returns the jump position in seconds and clears it.
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...
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 SetProgram(const ProgramInfo &pginfo)
ProgramInfo * GetSwitchProgram(bool &discont, bool &newtype, int &newid)
Returns the recording we should switch to.
std::chrono::seconds GetLengthAtCurPos(void)
bool NeedsToJump(void) const
Returns true iff a switch and jump are required.
QString GetInputType(int pos=-1) const
void EnableSubtitles(int Type, bool ForcedOnly=false)
MythScreenType * GetWindow(const QString &Window) override
void SendMessage(const QString &message)
double GetRefreshRate() const
std::chrono::microseconds GetRefreshInterval(std::chrono::microseconds Fallback) const
void GetAVSyncData(InfoMap &Map) const
std::chrono::microseconds AVSync(AudioPlayer *Audio, MythVideoFrame *Frame, std::chrono::microseconds FrameInterval, float PlaySpeed, bool HaveVideo, bool Force)
void SetRefreshInterval(std::chrono::microseconds interval)
void WaitForFrame(std::chrono::microseconds FrameDue)
std::chrono::milliseconds & DisplayTimecode()
virtual void SetTrack(uint Type, uint TrackNo)
InteractiveTV * GetInteractiveTV() override
void DoEnableForcedSubtitles()
void LoadExternalSubtitles()
void SetCaptionsEnabled(bool Enable, bool UpdateOSD=true)
MythCaptionsOverlay m_captionsOverlay
MythCaptionsState m_captionsState
void EnableSubtitles(bool Enable)
InteractiveTV * m_interactiveTV
void DoDisableForcedSubtitles()
void InitialiseState() override
QElapsedTimer m_editUpdateTimer
void UpdateOSDPosition()
Update the OSD status/position window.
void UpdateOSDMessage(const QString &Message)
void SetOSDStatus(const QString &Title, OSDTimeout Timeout)
QRecursiveMutex m_osdLock
virtual void PreProcessNormalFrame()
virtual void SetLastPlayPosition(uint64_t frame=0)
virtual void VideoStart()
MythPlayerUI(MythMainWindow *MainWindow, TV *Tv, PlayerContext *Context, PlayerFlags Flags)
void RenderVideoFrame(MythVideoFrame *Frame, FrameScanType Scan, bool Prepare, std::chrono::microseconds Wait)
void GetPlaybackData(InfoMap &Map)
virtual void InitialSeek()
virtual void SetBookmark(bool Clear=false)
void InitFrameInterval() override
virtual void DisplayPauseFrame()
virtual void EventStart()
bool CanSupportDoubleRate()
std::chrono::microseconds m_refreshInterval
void SetWatched(bool ForceWatched=false)
Determines if the recording should be considered watched.
void InitialiseState() override
void ChangeSpeed() override
void EnableBitrateMonitor(bool Enable=false)
void DoDisplayVideoFrame(MythVideoFrame *Frame, std::chrono::microseconds Due)
void GetCodecDescription(InfoMap &Map)
void JumpToStream(const QString &stream)
Jitterometer m_outputJmeter
virtual bool DisplayNormalFrame(bool CheckPrebuffer=true)
void ReinitVideo(bool ForceUpdate) override
void OSDDebugVisibilityChanged(bool Visible)
void EnableFrameRateMonitor(bool Enable=false)
void SetVideoParams(int Width, int Height, double FrameRate, float Aspect, bool ForceUpdate, int ReferenceFrames, FrameScanType Scan=kScan_Ignore, const QString &CodecName=QString()) override
DetectLetterbox m_detectLetterBox
void CheckAspectRatio(MythVideoFrame *Frame)
bool InitVideo() override
void AutoVisualise(bool HaveVideo)
Enable visualisation if possible, there is no video and user has requested.
bool m_checkAutoVisualise
void SetEof(EofState eof)
bool FlagIsSet(PlayerFlags arg)
std::chrono::microseconds m_frameInterval
always adjusted for play_speed
bool m_inJumpToProgramPause
virtual void SetVideoParams(int w, int h, double fps, float aspect, bool ForceUpdate, int ReferenceFrames, FrameScanType=kScan_Ignore, const QString &codecName=QString())
virtual bool HasReachedEof(void) const
uint64_t TranslatePositionMsToFrame(std::chrono::milliseconds position, bool use_cutlist) const
bool m_captionsEnabledbyDefault
This allows us to enable captions/subtitles later if the streams are not immediately available when t...
bool m_disableForcedSubtitles
virtual void DecoderStart(bool start_paused)
bool UpdateFFRewSkip(float ffrewScale=1.0F)
static const double kInaccuracyNone
void DoJumpToFrame(uint64_t frame, double inaccuracy)
uint64_t GetCurrentFrameCount(void) const
CommBreakMap m_commBreakMap
int m_fpsMultiplier
used to detect changes
void SeekingSlow(int Count)
long long CalcRWTime(long long rw) const
CalcRWTime(rw): rewind rw frames back.
void DiscardVideoFrames(bool KeyFrame, bool Flushed)
Places frames in the available frames queue.
virtual void ResetPlaying(bool resetframes=true)
virtual int OpenFile(int Retries=4)
virtual void InitFrameInterval()
virtual long long CalcMaxFFTime(long long ff, bool setjump=true) const
CalcMaxFFTime(ffframes): forward ffframes forward.
bool m_forcePositionMapSync
virtual void ReinitVideo(bool ForceUpdate)
std::chrono::seconds m_totalDuration
void SetErrored(const QString &reason)
bool IsNearEnd(void)
Returns true iff near end of recording.
bool IsWatchingInprogress(void) const
bool m_enableForcedSubtitles
bool IsErrored(void) const
QSize m_videoDispDim
Video (input) width & height.
bool volatile m_killDecoder
QSize m_videoDim
Video (input) buffer width & height.
virtual bool PrebufferEnoughFrames(int min_buffers=0)
MythPlayerAVSync m_avSync
void SetBuffering(bool new_buffering)
bool IsReallyNearEnd(void) const
Returns true iff really near end of recording.
float m_videoAspect
Video (input) Apect Ratio.
virtual bool DoJumpChapter(int chapter)
double m_videoFrameRate
Video (input) Frame Rate (often inaccurate)
void ClearAfterSeek(bool clearvideobuffers=true)
This is to support seeking...
virtual void ChangeSpeed(void)
long long m_ffTime
If m_ffTime>0, number of frames to seek forward.
std::chrono::milliseconds m_latestVideoTimecode
void SetPlayingInfo(const ProgramInfo &pginfo)
bool GetAllowForcedSubtitles(void) const
void UnpauseDecoder(void)
bool Play(float speed=1.0, bool normal=true, bool unpauseaudio=true)
bool m_hasFullPositionMap
void SetPlaying(bool is_playing)
PlayerContext * m_playerCtx
std::chrono::seconds m_totalLength
MythVideoOutput * m_videoOutput
bool DoRewind(uint64_t frames, double inaccuracy)
void SetFrameInterval(FrameScanType scan, double frame_period)
QString GetEncodingType(void) const
EofState GetEof(void) const
static const double kInaccuracyDefault
bool DoFastForward(uint64_t frames, double inaccuracy)
uint m_keyframeDist
Video (input) Number of frames between key frames (often inaccurate)
AdjustFillMode GetAdjustFill(void) const
void ToggleAdjustFill(AdjustFillMode AdjustFillMode=kAdjustFill_Toggle)
Sets up letterboxing for various standard video frame and monitor dimensions, then calls MoveResize()...
QRect GetDisplayVisibleRect(void) const
virtual void UpdatePauseFrame(std::chrono::milliseconds &, FrameScanType=kScan_Progressive)
virtual void StartDisplayingFrame()
Tell GetLastShownFrame() to return the next frame from the head of the queue of frames to display.
virtual void GetOSDBounds(QRect &Total, QRect &Visible, float &VisibleAspect, float &FontScaling, float ThemeAspect) const
virtual int ValidVideoFrames() const
Returns number of frames that are fully decoded.
virtual void EndFrame()=0
virtual void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan=kScan_Ignore)=0
virtual long long GetFramesPlayed()
virtual void RenderEnd()=0
virtual MythVideoFrame * GetLastShownFrame()
Returns frame from the head of the ready to be displayed queue, if StartDisplayingFrame has been call...
int FreeVideoFrames()
Returns number of frames available for decoding onto.
virtual void SetFramesPlayed(long long FramesPlayed)
virtual void DoneDisplayingFrame(MythVideoFrame *Frame)
Releases frame returned from GetLastShownFrame() onto the queue of frames ready for decoding onto.
virtual void RenderFrame(MythVideoFrame *Frame, FrameScanType)=0
FrameScanType GetScanForDisplay(MythVideoFrame *Frame, bool &SecondField)
FrameScanType DetectInterlace(FrameScanType NewScan, float Rate, int VideoHeight)
void SetScanType(FrameScanType Scan, MythVideoOutput *VideoOutput, std::chrono::microseconds FrameInterval)
void CheckScanUpdate(MythVideoOutput *VideoOutput, std::chrono::microseconds FrameInterval)
FrameScanType GetScanType() const
void InitialiseScan(MythVideoOutput *VideoOutput)
QString GetDeinterlacerName()
virtual void AutoDeint(MythVideoFrame *Frame, MythVideoOutput *VideoOutput, std::chrono::microseconds FrameInterval, bool AllowLock=true)
Check whether deinterlacing should be enabled.
void ResetWindow(const QString &Window)
bool Init(QRect Rect, float FontAspect) override
void HideWindow(const QString &Window) override
void SetText(const QString &Window, const InfoMap &Map, OSDTimeout Timeout)
void LockPlayingInfo(const char *file, int line) const
TVState GetState(void) const
void SetPlayerChangingBuffers(bool val)
bool IsRecorderErrored(void) const
MythMediaBuffer * m_buffer
void UnlockPlayingInfo(const char *file, int line) const
ProgramInfo * m_playingInfo
Currently playing info.
Holds information on recordings and videos.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
void SetIgnoreProgStart(bool ignore)
If "ignore" is true QueryProgStart() will return 0, otherwise QueryProgStart() will return the progst...
void SetIgnoreBookmark(bool ignore)
If "ignore" is true GetBookmark() will return 0, otherwise GetBookmark() will return the bookmark pos...
void SaveWatched(bool watchedFlag)
Set "watched" field in recorded/videometadata to "watchedFlag".
void UpdateInUseMark(bool force=false)
QDateTime GetScheduledEndTime(void) const
The scheduled end time of the program.
void SetIgnoreLastPlayPos(bool ignore)
If "ignore" is true QueryLastPlayPos() will return 0, otherwise QueryLastPlayPos() will return the la...
bool IsRecording(void) const
TranscodingStatus QueryTranscodeStatus(void) const
Returns the "transcoded" field in "recorded" table.
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
void SaveLastPlayPos(uint64_t frame)
TODO Move to RecordingInfo.
QString MakeUniqueKey(void) const
Creates a unique string that can be used to identify an existing recording.
QString GetPlaybackURL(bool checkMaster=false, bool forceCheckLocal=false)
Returns filename or URL to be used to play back this recording.
QDateTime GetRecordingEndTime(void) const
Approximate time the recording should have ended, did end, or is intended to end.
void SaveBookmark(uint64_t frame)
Clears any existing bookmark in DB and if frame is greater than 0 sets a new bookmark.
bool m_forced
Subtitle and RawText.
void UpdateLastPlayPosition(uint64_t frame)
void UpdateBookmark(bool Clear=false)
void InitialisePlayerState()
#define setpriority(x, y, z)
static constexpr const char * OSD_WIN_INTERACT
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static bool VERBOSE_LEVEL_CHECK(uint64_t mask, LogLevel_t level)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void SendMythSystemPlayEvent(const QString &msg, const ProgramInfo *pginfo)
QHash< QString, QString > InfoMap
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
def scan(profile, smoonURL, gate)
static constexpr const char * OSD_WIN_MESSAGE
static constexpr const char * OSD_WIN_DEBUG
static eu8 clamp(eu8 value, eu8 low, eu8 high)
@ kState_WatchingPreRecorded
Watching Pre-recorded is a TV only state for when we are watching a pre-existing recording.
bool is_interlaced(FrameScanType Scan)