Skip to content

Commit 64332c3

Browse files
authored
VPLAY-10806 AV playback stuck observed during profile reordering in multi-period streams. (#669)
VPLAY-10806 AV playback stuck observed during profile reordering in multi-period streams. Reason for change: If the Profile order changes across the periods, facing video stuck up issue as it retains the previous Representation index value during each period switch, so properly reset the Representation index during each period switch Risks: Low Test Procedure: Refer jira ticket Priority: P1 Signed-off-by: lashmintha <[email protected]>
1 parent 3746211 commit 64332c3

File tree

7 files changed

+69
-11
lines changed

7 files changed

+69
-11
lines changed

fragmentcollector_mpd.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,7 +3722,7 @@ AAMPStatusType StreamAbstractionAAMP_MPD::Init(TuneType tuneType)
37223722
}
37233723
// Update track with update in stream info
37243724
mUpdateStreamInfo = true;
3725-
ret = UpdateTrackInfo(!newTune, true);
3725+
ret = UpdateTrackInfo(!newTune, true, true);
37263726

37273727
if(eAAMPSTATUS_OK != ret)
37283728
{
@@ -4091,7 +4091,6 @@ AAMPStatusType StreamAbstractionAAMP_MPD::IndexNewMPDDocument(bool updateTrackIn
40914091
if(((AdState::IN_ADBREAK_AD_PLAYING != mCdaiObject->mAdState) && (AdState::IN_ADBREAK_WAIT2CATCHUP != mCdaiObject->mAdState))
40924092
|| (AdState::IN_ADBREAK_AD_PLAYING == mCdaiObject->mAdState && mUpdateStreamInfo))
40934093
{
4094-
AAMPLOG_TRACE("Indexing new mpd doc");
40954094
ret = UpdateTrackInfo(true, true);
40964095
if(ret != eAAMPSTATUS_OK)
40974096
{
@@ -7102,7 +7101,7 @@ static bool IsWebmVideoCodec(const std::string &codec )
71027101
/**
71037102
* @brief Updates track information based on current state
71047103
*/
7105-
AAMPStatusType StreamAbstractionAAMP_MPD::UpdateTrackInfo(bool modifyDefaultBW, bool resetTimeLineIndex)
7104+
AAMPStatusType StreamAbstractionAAMP_MPD::UpdateTrackInfo(bool modifyDefaultBW, bool resetTimeLineIndex, bool isInit)
71067105
{
71077106
AAMPStatusType ret = eAAMPSTATUS_OK;
71087107
long defaultBitrate = aamp->GetDefaultBitrate();
@@ -7288,10 +7287,9 @@ AAMPStatusType StreamAbstractionAAMP_MPD::UpdateTrackInfo(bool modifyDefaultBW,
72887287
// chosenAdaptationIdxs.insert(0);
72897288
}
72907289
}
7291-
if ((representationCount != GetProfileCount()) && mStreamInfo)
7290+
if ( periodChanged && mStreamInfo != nullptr )
72927291
{
72937292
SAFE_DELETE_ARRAY(mStreamInfo);
7294-
72957293
// reset representationIndex to -1 to allow updating the currentProfileIndex for period change.
72967294
pMediaStreamContext->representationIndex = -1;
72977295
AAMPLOG_WARN("representationIndex set to (-1) to find currentProfileIndex");
@@ -7576,7 +7574,20 @@ AAMPStatusType StreamAbstractionAAMP_MPD::UpdateTrackInfo(bool modifyDefaultBW,
75767574
}
75777575
UpdateIframeTracks();
75787576
}
7579-
currentProfileIndex = GetDesiredProfile(false);
7577+
/* During initialization its better to call the GetDesiredProfile(), which picks up the
7578+
* desired profile index corresponding to default bitrate.
7579+
* During subsequent 'period' change its better to call the getClosestProfileIndexByBandwidth()
7580+
* which picks up the profile index based on last bandwidth.
7581+
*/
7582+
if(isInit == true)
7583+
{
7584+
currentProfileIndex = GetDesiredProfile(false);
7585+
}
7586+
else
7587+
{
7588+
currentProfileIndex = GetABRManager().getClosestProfileIndexByBandwidth(pMediaStreamContext->fragmentDescriptor.Bandwidth);
7589+
}
7590+
AAMPLOG_INFO("Desired profile index updated [%d]",currentProfileIndex);
75807591
// Adaptation Set Index corresponding to a particular profile
75817592
pMediaStreamContext->adaptationSetIdx = mProfileMaps[currentProfileIndex].adaptationSetIndex;
75827593
// Representation Index within a particular Adaptation Set

fragmentcollector_mpd.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ class StreamAbstractionAAMP_MPD : public StreamAbstractionAAMP
842842
/**
843843
* @fn UpdateTrackInfo
844844
*/
845-
AAMPStatusType UpdateTrackInfo(bool modifyDefaultBW, bool resetTimeLineIndex = false);
845+
AAMPStatusType UpdateTrackInfo(bool modifyDefaultBW, bool resetTimeLineIndex = false, bool isInit = false);
846846
/**
847847
* @fn SkipToEnd
848848
* @param pMediaStreamContext Track object pointer
@@ -1132,7 +1132,6 @@ class StreamAbstractionAAMP_MPD : public StreamAbstractionAAMP
11321132
bool playlistDownloaderThreadStarted; // Playlist downloader thread start status
11331133
double mLivePeriodCulledSeconds;
11341134
bool mIsSegmentTimelineEnabled; /**< Flag to indicate if segment timeline is enabled, to determine if PTS is available from manifest */
1135-
11361135
// In case of streams with multiple video Adaptation Sets, A profile
11371136
// is a combination of an Adaptation Set and Representation within
11381137
// that Adaptation Set. Hence we need a mapping from a profile to

streamabstraction.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,7 +2625,6 @@ int StreamAbstractionAAMP::GetDesiredProfileBasedOnCache(void)
26252625
return desiredProfileIndex;
26262626
}
26272627

2628-
26292628
/**
26302629
* @brief Rampdown profile
26312630
*/
@@ -2988,7 +2987,6 @@ bool StreamAbstractionAAMP::UpdateProfileBasedOnFragmentCache()
29882987

29892988
return retVal;
29902989
}
2991-
29922990
/**
29932991
* @brief Check if playback has stalled and update related flags.
29942992
*/

support/aampabr/ABRManager.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,3 +730,41 @@ int ABRManager::getProfileIndexForLowestBandwidth()
730730
}
731731
return index;
732732
}
733+
/**
734+
* @brief Get the best matched profile index by bandwidth using sorted list
735+
*/
736+
int ABRManager::getClosestProfileIndexByBandwidth( long inputBandwidth )
737+
{
738+
std::lock_guard<std::mutex> lock(mProfileLock);
739+
// Use the first period's map
740+
if (!mSortedBWProfileList.empty())
741+
{
742+
int bestIdx = INVALID_PROFILE;
743+
auto& profileMap = mSortedBWProfileList.begin()->second;
744+
for (std::map<long, int>::const_iterator it = profileMap.begin(); it != profileMap.end(); ++it)
745+
{
746+
if (it->first > inputBandwidth)
747+
{
748+
break;
749+
}
750+
751+
bestIdx = it->second;
752+
#if defined(DEBUG_ENABLED)
753+
logprintf("%s:%d Matched bw:%ld idx:%d\n",__FUNCTION__, __LINE__,it->first, it->second);
754+
#endif
755+
}
756+
if( bestIdx == INVALID_PROFILE)
757+
{
758+
/* If the bandwidth of the current period is greater than the previous period, just return the initial profile index, having
759+
* lowest bandwidth
760+
*/
761+
bestIdx = profileMap.begin()->second;
762+
}
763+
return bestIdx;
764+
}
765+
else
766+
{
767+
//return 0th index for safer side
768+
return 0;
769+
}
770+
}

support/aampabr/ABRManager.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ class ABRManager {
191191
* @return int index for lowest bitrate
192192
*/
193193
int getProfileIndexForLowestBandwidth();
194+
/**
195+
* @fn getClosestProfileIndexByBandwidth
196+
*
197+
* @return int index for best matched bitrate
198+
*/
199+
int getClosestProfileIndexByBandwidth( long inputBandwidth );
200+
194201
public:
195202
// Getters/Setters
196203
/**

test/utests/fakes/FakeABRManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,8 @@ int ABRManager::getProfileIndexForLowestBandwidth()
116116
{
117117
return 0;
118118
}
119+
120+
int ABRManager::getClosestProfileIndexByBandwidth( long inputBandwidth )
121+
{
122+
return 0;
123+
}

test/utests/fakes/FakeStreamAbstractionAamp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,4 +534,4 @@ std::unique_ptr<SubtitleParser> StreamAbstractionAAMP::RegisterSubtitleParser_CB
534534
std::unique_ptr<SubtitleParser> StreamAbstractionAAMP::RegisterSubtitleParser_CB(SubtitleMimeType mimeType, bool isExpectedMimeType)
535535
{
536536
return nullptr;
537-
}
537+
}

0 commit comments

Comments
 (0)