VPAAMP 293 : Audio loss occurs when switching audio tracks in multiview streams - #1774
VPAAMP 293 : Audio loss occurs when switching audio tracks in multiview streams#1774Abhi-jith-S wants to merge 3 commits into
Conversation
Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>
Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>
There was a problem hiding this comment.
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 totfhdtrack_idwhentrakisn’t found. - Enhance
TfhdBoxto capture and optionally overwrite thetrack_idfield 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. |
| 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; | ||
| } |
| } | ||
| } | ||
|
|
||
| if ((actualType == eMEDIATYPE_INIT_AUDIO || actualType == eMEDIATYPE_AUDIO) && ret) |
| 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 | ||
| } | ||
| } |
| if (!ret && tfhdTrackFound) | ||
| { | ||
| track_id = tfhdTrackId; | ||
| ret = true; | ||
| } |
…nt branch Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>
|
Closing the PR now as we are waiting for approval of fix |
Reason for change : To overwrite track-id for audio tracks incase of mismatch
Test Procedure : Refer ticket