aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthexai <58434170+thexai@users.noreply.github.com>2023-02-27 15:33:02 +0100
committerthexai <58434170+thexai@users.noreply.github.com>2023-02-28 14:49:25 +0100
commitad8da8eb9a1c0b1748950d3c4564901c92863f24 (patch)
tree1c85e19b32b90aa60900bc82ab1ce5439a58bb17
parent08c0bbeaf307149f909f0227203909f5e9028b39 (diff)
VideoPlayer: add "estimated playback time of current cached bytes" at Debug Info OSD
-rw-r--r--xbmc/cores/VideoPlayer/VideoPlayer.cpp20
-rw-r--r--xbmc/cores/VideoPlayer/VideoPlayer.h8
2 files changed, 21 insertions, 7 deletions
diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp
index ba388af358..3b3f876eeb 100644
--- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp
+++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp
@@ -1824,12 +1824,14 @@ CacheInfo CVideoPlayer::GetCachingTimes()
if (length <= 0 || remain < 0)
return info;
+ double queueTime = GetQueueTime();
double play_sbp = DVD_MSEC_TO_TIME(m_pDemuxer->GetStreamLength()) / length;
- double queued = 1000.0 * GetQueueTime() / play_sbp;
+ double queued = 1000.0 * queueTime / play_sbp;
info.delay = 0.0;
info.level = 0.0;
info.offset = (cached + queued) / length;
+ info.time = 0.0;
info.valid = true;
if (currate == 0)
@@ -1840,7 +1842,11 @@ CacheInfo CVideoPlayer::GetCachingTimes()
double cache_left = cache_sbp * (remain - cached); /* time to cache the remaining bytes */
double cache_need = std::max(0.0, remain - play_left / cache_sbp); /* bytes needed until play_left == cache_left */
+ // estimated playback time of current cached bytes
+ double cache_time = (static_cast<double>(cached) / currate) + (queueTime / 1000.0);
+
info.delay = cache_left - play_left;
+ info.time = cache_time;
if (lowrate > 0)
{
@@ -3290,9 +3296,13 @@ void CVideoPlayer::GetGeneralInfo(std::string& strGeneralInfo)
std::unique_lock<CCriticalSection> lock(m_StateSection);
if (m_State.cache_bytes >= 0)
{
- strBuf += StringUtils::Format(" forward:{} {:2.0f}%",
- StringUtils::SizeToString(m_State.cache_bytes),
- m_State.cache_level * 100);
+ strBuf += StringUtils::Format("forward: {}", StringUtils::SizeToString(m_State.cache_bytes));
+
+ if (m_State.cache_time > 0)
+ strBuf += StringUtils::Format(" {:6.3f}s", m_State.cache_time);
+ else
+ strBuf += StringUtils::Format(" {:2.0f}%", m_State.cache_level * 100);
+
if (m_playSpeed == 0 || m_caching == CACHESTATE_FULL)
strBuf += StringUtils::Format(" {} msec", DVD_TIME_TO_MSEC(m_State.cache_delay));
}
@@ -4914,12 +4924,14 @@ void CVideoPlayer::UpdatePlayState(double timeout)
state.cache_delay = std::max(0.0, cache.delay);
state.cache_level = std::max(0.0, std::min(1.0, cache.level));
state.cache_offset = cache.offset;
+ state.cache_time = cache.time;
}
else
{
state.cache_delay = 0.0;
state.cache_level = std::min(1.0, queueTime / 8000.0);
state.cache_offset = queueTime / state.timeMax;
+ state.cache_time = queueTime / 1000.0;
}
XFILE::SCacheStatus status;
diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.h b/xbmc/cores/VideoPlayer/VideoPlayer.h
index b0373df7ac..daa0f2ad41 100644
--- a/xbmc/cores/VideoPlayer/VideoPlayer.h
+++ b/xbmc/cores/VideoPlayer/VideoPlayer.h
@@ -88,6 +88,7 @@ struct SPlayerState
double cache_level; // current estimated required cache level
double cache_delay; // time until cache is expected to reach estimated level
double cache_offset; // percentage of file ahead of current position
+ double cache_time; // estimated playback time of current cached bytes
};
class CDVDInputStream;
@@ -239,9 +240,10 @@ protected:
struct CacheInfo
{
- double level;
- double delay;
- double offset;
+ double level; // current estimated required cache level
+ double delay; // time until cache is expected to reach estimated level
+ double offset; // percentage of file ahead of current position
+ double time; // estimated playback time of current cached bytes
bool valid;
};