Skip to content

VPAAMP 293 : Audio loss occurs when switching audio tracks in multiview streams - #1774

Closed
Abhi-jith-S wants to merge 3 commits into
dev_sprint_25_2from
feature/VPAAMP_293_Sprint
Closed

VPAAMP 293 : Audio loss occurs when switching audio tracks in multiview streams#1774
Abhi-jith-S wants to merge 3 commits into
dev_sprint_25_2from
feature/VPAAMP_293_Sprint

Conversation

@Abhi-jith-S

Copy link
Copy Markdown
Contributor

Reason for change : To overwrite track-id for audio tracks incase of mismatch
Test Procedure : Refer ticket

Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>
Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.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

This PR aims to address audio loss during audio-track switches in multiview streams by detecting ISO-BMFF audio track_id mismatches across periods and overwriting the in-fragment track_id when needed. It also extends ISO-BMFF parsing to read track_id from tfhd boxes (for cases where trak may be absent in media fragments).

Changes:

  • Add MediaStreamContext::DetectMismatchAndOverwriteTrackId() and call it during audio/init-audio fragment caching.
  • Extend IsoBmffBuffer::getTrack_id() to fall back to tfhd track_id when trak isn’t found.
  • Enhance TfhdBox to capture and optionally overwrite the track_id field during TFHD construction.

Scores: Completeness 9/10, Assumptions 8/10, Clarity 9/10, CostRisk 4/10 | Critique: Solid diff/context provided across all touched files; moderate traversal cost due to multi-module touchpoints (MediaStreamContext + ISO-BMFF box/buffer). | Improve: Add a short “Expected behavioral change” and “When mismatch is detected (init vs media fragments)” note, plus explicit test references to run/extend.

Reviewed changes

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

File Description
MediaStreamContext.h Declares new helper to detect/handle audio track_id mismatches.
MediaStreamContext.cpp Implements mismatch detection and invokes it for audio fragment caching.
isobmff/isobmffbuffer.cpp Adds TFHD-based fallback when extracting track_id.
isobmff/isobmffbox.{h,cpp} Adds TFHD track_id storage/overwrite support in TfhdBox.

Comment thread MediaStreamContext.cpp
Comment on lines +85 to +100
uint32_t track_id = 0;
buffer.getTrack_id(track_id);

bool trackIdUpdated = false;
AAMPLOG_DEBUG("Audio track_id read from fragment: %d and track id stored in AAMP instance: %d", track_id, aamp->mCurrentAudioTrackId);
if (aamp->mCurrentAudioTrackId != -1 && track_id != aamp->mCurrentAudioTrackId)
{
buffer.parseBuffer(false, aamp->mCurrentAudioTrackId);
trackIdUpdated = true;
aamp->mIsTrackIdMismatch = true;
AAMPLOG_DEBUG("TrackId mismatch detected for audio, current track_id: %d, next period track_id: %d", aamp->mCurrentAudioTrackId, track_id);
}
if (!trackIdUpdated)
{
aamp->mCurrentAudioTrackId = track_id;
}
Comment thread MediaStreamContext.cpp
}
}

if ((actualType == eMEDIATYPE_INIT_AUDIO || actualType == eMEDIATYPE_AUDIO) && ret)
Comment thread isobmff/isobmffbuffer.cpp
Comment on lines +514 to +526
else if (IS_TYPE(box->getType(), Box::TFHD))
{
try {
TfhdBox *tfhdBox = dynamic_cast<TfhdBox *>(box);
if(tfhdBox)
{
tfhdTrackId = tfhdBox->getTrackId();
tfhdTrackFound = true;
}
} catch (std::bad_cast& bc){
//do nothing
}
}
Comment thread isobmff/isobmffbox.cpp
Comment thread isobmff/isobmffbuffer.cpp
Comment on lines +532 to +536
if (!ret && tfhdTrackFound)
{
track_id = tfhdTrackId;
ret = true;
}
…nt branch

Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>
@Abhi-jith-S

Copy link
Copy Markdown
Contributor Author

Closing the PR now as we are waiting for approval of fix

@Abhi-jith-S Abhi-jith-S closed this Aug 4, 2026
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