Skip to content

Conversation

@jfagunde
Copy link
Contributor

@jfagunde jfagunde commented Dec 3, 2025

Reason for Change: Change necessary prior to fixing VPLAY-11583

Summary of Changes:

  • Add ShouldCheckOnlyIframeAdaptation() helper function,
    which returns false for AAMP TSB
  • Add IsEmptyPeriod() helper function
  • Replace StreamAbstraction mPlayRate with the new helper functions
  • Improved functions comments

Test Procedure: No regressions with AAMP TSB

Risk: Low

Reason for Change: This needs fixing before we can fix VPLAY-11583

Summary of Changes:
* Call IsEmptyPeriod() with checkIframe=false for AAMP TSB
* Use aamp->rate instead of rate in IsEmptyPeriod()
* Improve comments and parameters name for GetPeriodDuration() and
  GetPeriodEndTime()

Test Procedure: Verify no regressions when using AAMP TSB

Risk: Low

Signed-off-by: Jose Fagundez <[email protected]>
Copilot AI review requested due to automatic review settings December 3, 2025 10:21
Copilot finished reviewing on behalf of jfagunde December 3, 2025 10:23
Copy link
Contributor

Copilot AI left a comment

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 refactors the logic for checking empty periods in MPEG-DASH playback to support AAMP TSB (Time Shift Buffer) functionality. The key change introduces two new helper functions that centralize the decision of whether to check only iframe adaptations when determining if a period is empty. When using local AAMP TSB, the code now checks all adaptations regardless of playback rate, since the iframe track is not used in TSB mode.

Key Changes:

  • Added ShouldCheckOnlyIframeAdaptation() helper to encapsulate the logic for determining whether to check only iframe adaptations based on playback rate and TSB mode
  • Added IsEmptyPeriod() wrapper that uses the new helper to call the underlying MPD parse helper
  • Replaced 30+ call sites throughout fragmentcollector_mpd.cpp to use the new centralized functions

Reviewed changes

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

File Description
fragmentcollector_mpd.h Added declarations for two new helper functions: ShouldCheckOnlyIframeAdaptation() and IsEmptyPeriod()
fragmentcollector_mpd.cpp Implemented the two new helper functions and refactored all call sites to use them instead of inline checks, centralizing TSB-aware logic
AampMPDParseHelper.h Improved documentation for GetPeriodDuration(), GetPeriodEndTime(), and UpdateBoundaryPeriod() with detailed parameter descriptions
AampMPDParseHelper.cpp Updated documentation for UpdateBoundaryPeriod() and GetPeriodEndTime() to clarify parameter meanings

Address review comments made by Copilot

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings December 3, 2025 10:49
Copilot finished reviewing on behalf of jfagunde December 3, 2025 10:52
Copy link
Contributor

Copilot AI left a comment

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 4 out of 4 changed files in this pull request and generated 1 comment.

Address review comment made by Copilot

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings December 3, 2025 10:54
Copilot finished reviewing on behalf of jfagunde December 3, 2025 10:58
Copy link
Contributor

Copilot AI left a comment

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 4 out of 4 changed files in this pull request and generated 6 comments.

@jfagunde jfagunde requested a review from Copilot December 5, 2025 13:19
Copilot finished reviewing on behalf of jfagunde December 5, 2025 13:22
Copy link
Contributor

Copilot AI left a comment

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 4 out of 4 changed files in this pull request and generated 2 comments.

Comment on lines +14215 to +14228
bool StreamAbstractionAAMP_MPD::ShouldCheckOnlyIframeAdaptation() const
{
// If playing at normal rate, check all adaptations.
// For trick modes, check only iframe adaptations (unless using AAMP TSB)
bool checkOnlyIframeAdaptation = (aamp->rate != AAMP_NORMAL_PLAY_RATE);

// When using local AAMP TSB, i/frame track is not used,
// so check all adaptations regardless of playback rate.
if (aamp->IsLocalAAMPTsb())
{
checkOnlyIframeAdaptation = false;
}

return checkOnlyIframeAdaptation;
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The ShouldCheckOnlyIframeAdaptation() helper uses aamp->rate directly, which differs from the original behavior that captured currentRate at the start of Init() (line 3198) and used that snapshot throughout the function. This change means the rate is now evaluated dynamically on each call rather than using a consistent snapshot.

If aamp->rate can change during the execution of Init() or other methods, this could lead to inconsistent behavior where different calls to IsEmptyPeriod() or GetPeriodDuration() within the same method use different rate values.

Consider one of these approaches:

  1. If the rate is guaranteed not to change during these operations, document this assumption clearly
  2. If the rate can change, restore the original behavior by passing the rate as a parameter to the helper functions
  3. Add synchronization to ensure consistent rate evaluation

Since this affects TSB behavior (the primary purpose of this PR), this behavioral change should be explicitly validated.

Copilot uses AI. Check for mistakes.
Comment on lines +14215 to +14239
bool StreamAbstractionAAMP_MPD::ShouldCheckOnlyIframeAdaptation() const
{
// If playing at normal rate, check all adaptations.
// For trick modes, check only iframe adaptations (unless using AAMP TSB)
bool checkOnlyIframeAdaptation = (aamp->rate != AAMP_NORMAL_PLAY_RATE);

// When using local AAMP TSB, i/frame track is not used,
// so check all adaptations regardless of playback rate.
if (aamp->IsLocalAAMPTsb())
{
checkOnlyIframeAdaptation = false;
}

return checkOnlyIframeAdaptation;
}

/**
* @fn IsEmptyPeriod
* @param[in] iPeriodIndex Index of the period to check whether it is empty
* @retval Return true on empty Period
*/
bool StreamAbstractionAAMP_MPD::IsEmptyPeriod(int iPeriodIndex) const
{
return mMPDParseHelper->IsEmptyPeriod(iPeriodIndex, ShouldCheckOnlyIframeAdaptation());
}
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The new helper functions ShouldCheckOnlyIframeAdaptation() and IsEmptyPeriod() lack test coverage. Given that:

  1. These functions encapsulate critical TSB-specific logic
  2. The PR description states "Change necessary prior to fixing VPLAY-11583"
  3. Similar components like AampTsbReader, AampTsbDataManager have comprehensive test coverage in test/utests/tests/

Unit tests should be added to verify:

  • Normal playback rate returns false for ShouldCheckOnlyIframeAdaptation()
  • Trick mode (non-normal rate) returns true when not using AAMP TSB
  • AAMP TSB mode always returns false regardless of rate
  • IsEmptyPeriod() correctly delegates to mMPDParseHelper->IsEmptyPeriod() with the right parameter

Copilot uses AI. Check for mistakes.
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