Skip to content

VPAAMP-163: Latency is fluctuating during normal playback in Linear/S…#1643

Open
psiva01 wants to merge 6 commits into
dev_sprint_25_2from
feature/VPAAMP-163
Open

VPAAMP-163: Latency is fluctuating during normal playback in Linear/S…#1643
psiva01 wants to merge 6 commits into
dev_sprint_25_2from
feature/VPAAMP-163

Conversation

@psiva01

@psiva01 psiva01 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

…LE assets

Reason for change: Code changes to prefer EXT-X-PROGRAM-DATE-TIME-based latency for HLS live/linear when it's available, with fallback to existing logic.

…LE assets

Reason for change: Code changes to prefer EXT-X-PROGRAM-DATE-TIME-based latency
for HLS live/linear when it's available, with fallback to existing logic.

Signed-off-by: psiva01 <sivasubramanian.patchaiperumal@ltts.com>
@psiva01 psiva01 requested a review from a team as a code owner June 23, 2026 09:50
@psiva01 psiva01 requested a review from Copilot June 23, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates AAMP’s live HLS latency calculation to prefer an EXT-X-PROGRAM-DATE-TIME (PDT) wall-clock-derived latency when available, falling back to the existing live-edge-based calculation otherwise, aiming to reduce latency fluctuations during linear playback.

Changes:

  • Add PDT-based HLS live latency derivation in PrivateInstanceAAMP::MonitorProgress() when mProgramDateTime is available.
  • Keep existing live-edge latency calculation as a fallback path.
  • Extend periodic “aamp pos” progress logging to include PDT-latency and edge-latency values.

Comment thread priv_aamp.cpp Outdated
Comment thread priv_aamp.cpp
Comment on lines +2524 to +2529
// Fallback: calculate HLS live latency based on live edge.
latency = hlsEdgeLatencyMs;
if(latency < 0)
{ // this should never happen!
AAMPLOG_ERR("HLS negative live latency = %ldms, end = %lfms, reportFormattedCurrPos = %lfms", latency, end, reportFormattedCurrPos);
}
Comment thread priv_aamp.cpp Outdated
Comment on lines +2506 to +2510
if (mProgramDateTime > 0.0)
{
// Convert current playback position to absolute UTC using the playlist
// start PDT, then derive live latency from current wall-clock time.
const double playbackUtcMs = (mProgramDateTime * 1000.0) +

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add this test.

psiva01 and others added 5 commits June 23, 2026 15:33
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: psiva01 <sivasubramanian.patchaiperumal@ltts.com>
Signed-off-by: psiva01 <sivasubramanian.patchaiperumal@ltts.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread priv_aamp.cpp
Comment on lines +2501 to +2525
bool hlsPdtLatencyEnabled =
ISCONFIGSET_PRIV(eAAMPConfig_EnableHLSPDTLatency);
if (hlsPdtLatencyEnabled && mProgramDateTime > 0.0)
{
// Convert current playback position to absolute UTC using the playlist
// start PDT, then derive live latency from current wall-clock time.
const double playbackUtcMs = (mProgramDateTime * 1000.0) +
(reportFormattedCurrPos - start);
long hlsPdtLatencyMs = static_cast<long>(std::llround(
aamp_GetCurrentTimeMS() - playbackUtcMs));
if (hlsPdtLatencyMs > 0)
{
latency = hlsPdtLatencyMs;
}
else
{
AAMPLOG_ERR("HLS negative live latency (PDT) = %ldms, mProgramDateTime = %lf, reportFormattedCurrPos = %lfms, start = %lfms", hlsPdtLatencyMs, mProgramDateTime, reportFormattedCurrPos, start);
}
}

if (latency == 0)
{
AAMPLOG_DEBUG("HLS live latency using live-edge latency. HLS PDT latency config %d, mProgramDateTime %lf", hlsPdtLatencyEnabled, mProgramDateTime);

// Fallback: calculate HLS live latency based on live edge.
Comment thread AampConfig.cpp
{false,"dashIgnoreBaseUrlIfSlash",eAAMPConfig_DASHIgnoreBaseURLIfSlash,false},
{false,"licenseAnonymousRequest",eAAMPConfig_AnonymousLicenseRequest,false},
{false,"hlsAVTrackSyncUsingPDT",eAAMPConfig_HLSAVTrackSyncUsingStartTime,false},
{true,"enableHlsPdtLatency",eAAMPConfig_EnableHLSPDTLatency,false},
Comment thread priv_aamp.cpp
Comment on lines +2507 to +2511
const double playbackUtcMs = (mProgramDateTime * 1000.0) +
(reportFormattedCurrPos - start);
long hlsPdtLatencyMs = static_cast<long>(std::llround(
aamp_GetCurrentTimeMS() - playbackUtcMs));
if (hlsPdtLatencyMs > 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants