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");
588 LOG(VB_PLAYBACK, LOG_DEBUG,
LOC + QString(
"timecode video:%1 audio:%2")
610 LOG(VB_PLAYBACK, LOG_DEBUG, QString(
"Clearing render one"));
617 bool showsecondfield =
false;
627 bool olddeinterlaced =
Frame->m_alreadyDeinterlaced;
629 Frame->m_alreadyDeinterlaced =
false;
635 if (!showsecondfield && secondprepare)
637 Frame->m_alreadyDeinterlaced = olddeinterlaced;
639 else if (showsecondfield)
660 SetErrored(tr(
"Serious error detected in Video Output"));
727 bool ForceUpdate,
int ReferenceFrames,
779 qint64 endtime = std::min(endactual, endsched);
780 numFrames =
static_cast<uint64_t
>((endtime - starttime) *
m_videoFrameRate);
784 auto offset = std::chrono::seconds(lround(0.14 * (numFrames /
m_videoFrameRate)));
790 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Marking recording as watched using offset %1 minutes")
791 .arg(offset.count()/60));
822 return (duration_cast<floatusecs>(realfi) / 2.0) > (duration_cast<floatusecs>(
m_refreshInterval) * 0.995);
828 Map.insert(
"samplerate", samplerate);
840 Map.insert(
"videoframes", frames);
845 Map[
"framerate"] = QString(
"%1%2%3")
852 QString displayfps = QString(
"%1x%2@%3Hz")
856 Map[
"displayfps"] = displayfps;
869 Map[
"videowidth"] = QString::number(width);
870 Map[
"videoheight"] = QString::number(height);
879 Map[
"videodescrip"] = interlaced ?
"UHD_4K_I" :
"UHD_4K_P";
880 else if (width == 1920 || height == 1080 || height == 1088)
881 Map[
"videodescrip"] = interlaced ?
"HD_1080_I" :
"HD_1080_P";
882 else if ((width == 1280 || height == 720) && !interlaced)
883 Map[
"videodescrip"] =
"HD_720_P";
884 else if (height >= 720)
885 Map[
"videodescrip"] =
"HD";
887 Map[
"videodescrip"] =
"SD";
951 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"JumpToStream - begin");
954 if (stream.isEmpty())
970 LOG(VB_GENERAL, LOG_ERR,
LOC +
"JumpToStream buffer OpenFile failed");
972 SetErrored(tr(
"Error opening remote stream buffer"));
984 LOG(VB_GENERAL, LOG_ERR,
LOC +
"JumpToStream OpenFile failed.");
986 SetErrored(tr(
"Error opening remote stream"));
997 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"JumpToStream length %1 bytes @ %2 Kbps = %3 Secs, %4 frames @ %5 fps")
1015 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"JumpToStream - end");
1023 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"SwitchToProgram - start");
1024 bool discontinuity =
false;
1025 bool newtype =
false;
1062 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"SwitchToProgram's OpenFile failed (input type: %1)")
1066 SetErrored(tr(
"Error opening switch program buffer"));
1073 discontinuity =
true;
1077 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"SwitchToProgram(void) "
1078 "discont: %1 newtype: %2 newid: %3 decoderEof: %4")
1079 .arg(discontinuity).arg(newtype).arg(newid).arg(
GetEof()));
1081 if (discontinuity || newtype)
1091 SetErrored(tr(
"Error opening switch program file"));
1111 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SwitchToProgram failed.");
1123 if (discontinuity || newtype)
1130 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"SwitchToProgram - end");
1135 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"JumpToProgram - start");
1136 bool discontinuity =
false;
1137 bool newtype =
false;
1183 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"JumpToProgram's OpenFile failed (input type: %1)")
1187 SetErrored(tr(
"Error opening jump program file buffer"));
1196 if (newtype || wasDummy)
1199 SetErrored(tr(
"Error opening jump program file"));
1208 LOG(VB_GENERAL, LOG_ERR,
LOC +
"JumpToProgram failed.");
1210 SetErrored(tr(
"Error reopening video decoder"));
1237 if (nextpos > (duration - maxpos))
1239 nextpos = duration - maxpos;
1243 else if (nextpos < 0s)
1246 nextpos += duration;
1256 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
std::chrono::milliseconds m_latestAudioTimecode
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)