VPAAMP-163: Latency is fluctuating during normal playback in Linear/S…#1643
Open
psiva01 wants to merge 6 commits into
Open
VPAAMP-163: Latency is fluctuating during normal playback in Linear/S…#1643psiva01 wants to merge 6 commits into
psiva01 wants to merge 6 commits into
Conversation
…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>
Contributor
There was a problem hiding this comment.
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()whenmProgramDateTimeis 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 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 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) + |
Contributor
Author
There was a problem hiding this comment.
@copilot add this test.
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>
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. |
| {false,"dashIgnoreBaseUrlIfSlash",eAAMPConfig_DASHIgnoreBaseURLIfSlash,false}, | ||
| {false,"licenseAnonymousRequest",eAAMPConfig_AnonymousLicenseRequest,false}, | ||
| {false,"hlsAVTrackSyncUsingPDT",eAAMPConfig_HLSAVTrackSyncUsingStartTime,false}, | ||
| {true,"enableHlsPdtLatency",eAAMPConfig_EnableHLSPDTLatency,false}, |
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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.