-
Notifications
You must be signed in to change notification settings - Fork 9
VPAAMP-205 eliminate recursion concerns in HandleSeekEOSAndPeriodTransition #1375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: support/2.11.1_8.4_vipa
Are you sure you want to change the base?
Changes from all commits
c97d46c
b8a956f
d33a53d
7396ccd
6a77320
27c9028
242dace
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2287,21 +2287,24 @@ bool StreamAbstractionAAMP_MPD::PushNextFragment( class MediaStreamContext *pMed | |||||
| * @brief If SkipFragments reaches EOS and an additional playable period is available, switch to the next period. | ||||||
| */ | ||||||
| bool StreamAbstractionAAMP_MPD::HandleSeekEOSAndPeriodTransition(double remainingSeek, | ||||||
| bool skipToEnd) | ||||||
| bool /*skipToEnd*/) // reserved for future use; see header for rationale | ||||||
| { | ||||||
| bool switchToNextPeriod = false; | ||||||
|
|
||||||
| // Check whether any track hit EOS during the seek. Any enabled track reaching EOS | ||||||
| // is sufficient to trigger a period transition: DASH spec requires all tracks in a | ||||||
| // period to end at the same presentation time, so this is safe for well-formed content. | ||||||
| // The mPlayRate and remainingSeek guards (comment 2 & 3) prevent false positives: | ||||||
| // Check whether any enabled track hit EOS during the seek. Only enabled tracks | ||||||
| // participate in playback; a disabled or unselected track (e.g. an alternate audio | ||||||
| // track, or a subtitle track when subtitles are off) may carry stale eos=true from | ||||||
| // a prior operation and must not trigger a spurious period transition. | ||||||
| // DASH spec requires all tracks in a period to end at the same presentation time, | ||||||
| // so any single enabled track reaching EOS is sufficient. | ||||||
| // The mPlayRate and remainingSeek guards prevent false positives: | ||||||
| // - mPlayRate >= AAMP_RATE_PAUSE: for reverse playback (mPlayRate < 0), EOS means | ||||||
| // beginning-of-period, not end-of-period, so we must not advance to the next period. | ||||||
| // - remainingSeek >= 0: a negative remainder also indicates the seek overshot backward | ||||||
| // rather than forward, so no forward period transition is appropriate. | ||||||
| for (int i = 0; i < mNumberOfTracks; i++) | ||||||
| { | ||||||
| if (mMediaStreamContext[i] != NULL && mMediaStreamContext[i]->eos && (mPlayRate >= AAMP_RATE_PAUSE) && remainingSeek >= 0) | ||||||
| if (mMediaStreamContext[i] != nullptr && mMediaStreamContext[i]->enabled && mMediaStreamContext[i]->eos && (mPlayRate >= AAMP_RATE_PAUSE) && remainingSeek >= 0) | ||||||
| { | ||||||
| switchToNextPeriod = true; | ||||||
| break; | ||||||
|
|
@@ -2326,6 +2329,15 @@ bool StreamAbstractionAAMP_MPD::HandleSeekEOSAndPeriodTransition(double remainin | |||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| // Save current period state so we can restore it if UpdateTrackInfo fails, | ||||||
| // leaving the object in a consistent state rather than half-switched. | ||||||
| const int savedPeriodIdx = mCurrentPeriodIdx; | ||||||
| IPeriod *savedPeriod = mCurrentPeriod; | ||||||
| std::string savedBasePeriodId = mBasePeriodId; | ||||||
| const double savedPeriodStart = mPeriodStartTime; | ||||||
| const double savedPeriodDuration = mPeriodDuration; | ||||||
| const double savedPeriodEnd = mPeriodEndTime; | ||||||
|
|
||||||
| mCurrentPeriodIdx = nextPeriodIdx; | ||||||
| mCurrentPeriod = mpd->GetPeriods().at(mCurrentPeriodIdx); | ||||||
| mBasePeriodId = mCurrentPeriod->GetId(); | ||||||
|
|
@@ -2338,18 +2350,19 @@ bool StreamAbstractionAAMP_MPD::HandleSeekEOSAndPeriodTransition(double remainin | |||||
| AAMPStatusType ret = UpdateTrackInfo(true, true); | ||||||
| if (ret != eAAMPSTATUS_OK) | ||||||
| { | ||||||
| AAMPLOG_WARN("SeekInPeriod: UpdateTrackInfo failed while switching to period %d", mCurrentPeriodIdx); | ||||||
| AAMPLOG_WARN("SeekInPeriod: UpdateTrackInfo failed while switching to period %d, restoring previous period state", mCurrentPeriodIdx); | ||||||
| mCurrentPeriodIdx = savedPeriodIdx; | ||||||
| mCurrentPeriod = savedPeriod; | ||||||
| mBasePeriodId = savedBasePeriodId; | ||||||
| mPeriodStartTime = savedPeriodStart; | ||||||
| mPeriodDuration = savedPeriodDuration; | ||||||
| mPeriodEndTime = savedPeriodEnd; | ||||||
| return false; | ||||||
|
Comment on lines
+2353
to
2360
|
||||||
| } | ||||||
|
|
||||||
| AAMPLOG_INFO("SeekInPeriod: Switched to period %d, calling SkipFragments with remaining seek %lf", mCurrentPeriodIdx, remainingSeek); | ||||||
| AAMPLOG_INFO("SeekInPeriod: Switched to period %d; caller will re-run SkipFragments on the new period with remaining seek %lf", mCurrentPeriodIdx, remainingSeek); | ||||||
|
||||||
| AAMPLOG_INFO("SeekInPeriod: Switched to period %d; caller will re-run SkipFragments on the new period with remaining seek %lf", mCurrentPeriodIdx, remainingSeek); | |
| AAMPLOG_INFO("SeekInPeriod: Switched to period %d; caller will re-run SkipFragments on the new period with remaining seek %lf", mCurrentPeriodIdx, remainingSeek); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3942,6 +3942,7 @@ R"(<?xml version="1.0" encoding="utf-8"?> | |||||
| MediaTrack *track = mStreamAbstractionAAMP_MPD->GetMediaTrack(eTRACK_VIDEO); | ||||||
| ASSERT_NE(track, nullptr); | ||||||
| MediaStreamContext *pMediaStreamContext = static_cast<MediaStreamContext *>(track); | ||||||
| (void)pMediaStreamContext; | ||||||
|
Comment on lines
3944
to
+3945
|
||||||
| MediaStreamContext *pMediaStreamContext = static_cast<MediaStreamContext *>(track); | |
| (void)pMediaStreamContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HandleSeekEOSAndPeriodTransition() decides to advance periods when any enabled track has eos=true. This includes subtitles, but the main fetch loop’s EOS gating ignores subtitles (it only checks video/audio; see fragmentcollector_mpd.cpp:10338-10341). If subtitle segments end earlier (or are missing) than A/V, a seek could incorrectly advance to the next period. Consider restricting the EOS check here to video/audio (and any other A/V-carrying tracks you intend) rather than iterating all tracks indiscriminately.