From bad9194fb87420c447a43bfd852b8f2dc0230aac Mon Sep 17 00:00:00 2001 From: psiva01 Date: Wed, 13 May 2026 20:10:13 +0530 Subject: [PATCH 1/5] VPAAMP-245: Negative Latency value logged while HLS linear playback w/o TSB Reason for change: EndPos is set to -1 for TSB-less playback before latency calculation. This caused latency to be negative, since HLS latency is calculated as EndPos - CurrPos. So, moved this tsbless block after latency calculation. Also, fixed start and end values in aamp pos logging. Signed-off-by: psiva01 --- priv_aamp.cpp | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/priv_aamp.cpp b/priv_aamp.cpp index 031c73f39..dfdf433d1 100644 --- a/priv_aamp.cpp +++ b/priv_aamp.cpp @@ -2695,15 +2695,6 @@ void PrivateInstanceAAMP::MonitorProgress(bool sync, bool beginningOfStream) end -= offset; } - // If tsb is not available for linear send -1 for start and end - // so that xre detect this as tsbless playback - // Override above logic if mEnableSeekableRange is set, used by third-party apps - if (!ISCONFIGSET_PRIV(eAAMPConfig_EnableSeekRange) && (mContentType == ContentType_LINEAR && !mFogTSBEnabled && !IsLocalAAMPTsb())) - { - start = -1; - end = -1; - } - if(IsLiveStream()) { if(eMEDIAFORMAT_DASH == mMediaFormat) @@ -2737,6 +2728,15 @@ void PrivateInstanceAAMP::MonitorProgress(bool sync, bool beginningOfStream) } } + // If tsb is not available for linear send -1 for start and end + // so that xre detect this as tsbless playback + // Override above logic if mEnableSeekableRange is set, used by third-party apps + if (!ISCONFIGSET_PRIV(eAAMPConfig_EnableSeekRange) && (mContentType == ContentType_LINEAR && !mFogTSBEnabled && !IsLocalAAMPTsb())) + { + start = -1; + end = -1; + } + const BitsPerSecond availableBandwidth = mhAbrManager.GetCurrentlyAvailableBandwidth(); const BitsPerSecond networkBandwidth = mhAbrManager.GetNetworkBandwidth(); @@ -2803,24 +2803,28 @@ void PrivateInstanceAAMP::MonitorProgress(bool sync, bool beginningOfStream) SETCONFIGVALUE_PRIV(AAMP_STREAM_SETTING, eAAMPConfig_ProgressLogging, false); } } + if (ISCONFIGSET_PRIV(eAAMPConfig_ProgressLogging)) { static int tick; int divisor = GETCONFIGVALUE_PRIV(eAAMPConfig_ProgressLoggingDivisor); if( divisor==0 || (tick++ % divisor) == 0 ) { + auto format_pos = [](double val) -> long { + return (val == -1.0) ? -1 : (long)(val / 1000); + }; AAMPLOG_MIL("aamp pos: [%ld..%ld..%ld..%lld..%.2f..%.2f..%.2f..%s..%" BITSPERSECOND_FORMAT "..%" BITSPERSECOND_FORMAT "..%.2f]", - (long)(start / 1000), - (long)(reportFormattedCurrPos / 1000), - (long)(end / 1000), - (long long) videoPTS, - (double)(videoBufferedDuration / 1000.0), - (double)(audioBufferedDuration /1000.0), - (double)(latency / 1000.0), - seiTimecode.c_str(), - bps, - networkBandwidth, - currentRate); + format_pos(start), + (long)(reportFormattedCurrPos / 1000), + format_pos(end), + (long long) videoPTS, + (double)(videoBufferedDuration / 1000.0), + (double)(audioBufferedDuration /1000.0), + (double)(latency / 1000.0), + seiTimecode.c_str(), + bps, + networkBandwidth, + currentRate); } } From ea0052206c53f47a92ba59ee093f1c5eb6559276 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 07:04:32 +0000 Subject: [PATCH 2/5] Rename format_pos lambda to formatPos and val parameter to valMs for camelCase consistency Agent-Logs-Url: https://github.com/rdkcentral/aamp/sessions/58db369a-2b08-48fe-a19c-a00c2fc4ec61 Co-authored-by: psiva01 <214551386+psiva01@users.noreply.github.com> --- priv_aamp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/priv_aamp.cpp b/priv_aamp.cpp index dfdf433d1..79f0eb618 100644 --- a/priv_aamp.cpp +++ b/priv_aamp.cpp @@ -2810,13 +2810,13 @@ void PrivateInstanceAAMP::MonitorProgress(bool sync, bool beginningOfStream) int divisor = GETCONFIGVALUE_PRIV(eAAMPConfig_ProgressLoggingDivisor); if( divisor==0 || (tick++ % divisor) == 0 ) { - auto format_pos = [](double val) -> long { - return (val == -1.0) ? -1 : (long)(val / 1000); + auto formatPos = [](double valMs) -> long { + return (valMs == -1.0) ? -1 : (long)(valMs / 1000); }; AAMPLOG_MIL("aamp pos: [%ld..%ld..%ld..%lld..%.2f..%.2f..%.2f..%s..%" BITSPERSECOND_FORMAT "..%" BITSPERSECOND_FORMAT "..%.2f]", - format_pos(start), + formatPos(start), (long)(reportFormattedCurrPos / 1000), - format_pos(end), + formatPos(end), (long long) videoPTS, (double)(videoBufferedDuration / 1000.0), (double)(audioBufferedDuration /1000.0), From ea9efdec40cb40f748f6de4987fbe6b5bb1f99df Mon Sep 17 00:00:00 2001 From: Sivasubramanian Patchaiperumal Date: Thu, 14 May 2026 12:36:26 +0530 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- priv_aamp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/priv_aamp.cpp b/priv_aamp.cpp index 79f0eb618..e539c4fe9 100644 --- a/priv_aamp.cpp +++ b/priv_aamp.cpp @@ -2728,9 +2728,9 @@ void PrivateInstanceAAMP::MonitorProgress(bool sync, bool beginningOfStream) } } - // If tsb is not available for linear send -1 for start and end - // so that xre detect this as tsbless playback - // Override above logic if mEnableSeekableRange is set, used by third-party apps + // If TSB is not available for linear playback, send -1 for start and end + // so that XRE detects this as TSB-less playback. + // Override the above logic when mEnableSeekableRange is set for third-party apps. if (!ISCONFIGSET_PRIV(eAAMPConfig_EnableSeekRange) && (mContentType == ContentType_LINEAR && !mFogTSBEnabled && !IsLocalAAMPTsb())) { start = -1; From e5916da880500209d763d6ee33356f75d65d144d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 07:15:33 +0000 Subject: [PATCH 4/5] Add regression test for VPAAMP-245: TSB-less linear HLS latency non-negative Agent-Logs-Url: https://github.com/rdkcentral/aamp/sessions/447d113b-da77-41be-a441-b021ef3f8bb8 Co-authored-by: psiva01 <214551386+psiva01@users.noreply.github.com> --- .../tests/PrivAampTests/PrivAampTests.cpp | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/utests/tests/PrivAampTests/PrivAampTests.cpp b/test/utests/tests/PrivAampTests/PrivAampTests.cpp index c0b03af46..a7ea777ec 100644 --- a/test/utests/tests/PrivAampTests/PrivAampTests.cpp +++ b/test/utests/tests/PrivAampTests/PrivAampTests.cpp @@ -1629,6 +1629,45 @@ TEST_F(PrivAampTests, MonitorProgressRewindToBoS_ProgressBeforeSpeedChange) p_aamp->MonitorProgress(true, false); } +/** + * @brief Regression test for VPAAMP-245. + * + * Verifies that live latency is never negative during TSB-less linear HLS + * playback. Before the fix, start/end were overwritten to -1 (XRE sentinel) + * before HLS latency was calculated (latency = end - position), producing a + * large negative latency value. The fix moves the sentinel assignment to after + * the latency calculation. + */ +TEST_F(PrivAampTests, MonitorProgress_TsbLessLinearHLS_LatencyNonNegative) +{ + constexpr double CULLED_SECONDS = 0.0; + constexpr double DURATION_SECONDS = 1000.0; + constexpr double SEEK_POS_SECONDS = 100.0; + + // Setup: TSB-less linear HLS live playback + p_aamp->SetState(eSTATE_PLAYING, true); + p_aamp->mDownloadsEnabled = true; + p_aamp->rate = AAMP_NORMAL_PLAY_RATE; + p_aamp->mSinkPaused = false; + p_aamp->mMediaFormat = eMEDIAFORMAT_HLS; + p_aamp->SetIsLiveStream(true); + p_aamp->mContentType = ContentType_LINEAR; + p_aamp->mFogTSBEnabled = false; + p_aamp->SetLocalAAMPTsb(false); + p_aamp->durationSeconds = DURATION_SECONDS; + p_aamp->culledSeconds = CULLED_SECONDS; + p_aamp->seek_pos_seconds = SEEK_POS_SECONDS; + p_aamp->trickStartUTCMS = -1; + + EXPECT_CALL(*g_mockAampConfig, IsConfigSet(_)).WillRepeatedly(Return(false)); + EXPECT_CALL(*g_mockAampStreamSinkManager, GetStreamSink(_)).WillRepeatedly(Return(g_mockAampGstPlayer)); + + p_aamp->MonitorProgress(true, false); + + // Live latency must be non-negative after the fix. + EXPECT_GE(p_aamp->GetCurrentLatencyMs(), 0L); +} + TEST_F(PrivAampTests,UpdateDurationTest) { p_aamp->UpdateDuration(232.436); From b9182bc84112d5bb8a7343cc8653359acef37323 Mon Sep 17 00:00:00 2001 From: psiva01 Date: Thu, 14 May 2026 20:31:37 +0530 Subject: [PATCH 5/5] VPAAMP-245: fix L1 failure Signed-off-by: psiva01 --- test/utests/tests/PrivAampTests/PrivAampTests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/utests/tests/PrivAampTests/PrivAampTests.cpp b/test/utests/tests/PrivAampTests/PrivAampTests.cpp index a7ea777ec..c59fe5e65 100644 --- a/test/utests/tests/PrivAampTests/PrivAampTests.cpp +++ b/test/utests/tests/PrivAampTests/PrivAampTests.cpp @@ -1630,7 +1630,7 @@ TEST_F(PrivAampTests, MonitorProgressRewindToBoS_ProgressBeforeSpeedChange) } /** - * @brief Regression test for VPAAMP-245. + * @brief Regression test for Positive Live latency value. * * Verifies that live latency is never negative during TSB-less linear HLS * playback. Before the fix, start/end were overwritten to -1 (XRE sentinel) @@ -1651,7 +1651,7 @@ TEST_F(PrivAampTests, MonitorProgress_TsbLessLinearHLS_LatencyNonNegative) p_aamp->mSinkPaused = false; p_aamp->mMediaFormat = eMEDIAFORMAT_HLS; p_aamp->SetIsLiveStream(true); - p_aamp->mContentType = ContentType_LINEAR; + p_aamp->SetContentType("LINEAR_TV"); p_aamp->mFogTSBEnabled = false; p_aamp->SetLocalAAMPTsb(false); p_aamp->durationSeconds = DURATION_SECONDS;