VPAAMP 293 : Audio loss occurs when switching audio tracks in multiview streams - #1775
VPAAMP 293 : Audio loss occurs when switching audio tracks in multiview streams#1775Abhi-jith-S wants to merge 6 commits into
Conversation
Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>
Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>
Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>
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
Addresses audio loss during audio-track switches in multiview MP4 streams by detecting track-id mismatches and rewriting the fragment track-id to match the currently selected audio track.
Changes:
- Extends track-id inspection/overwrite logic to include non-init audio fragments in
MediaStreamContext::CacheFragment. - Enhances ISO-BMFF parsing to extract track-id from
tfhdwhentrakisn’t present (typical for media fragments). - Adds
TfhdBoxsupport for reading/overwriting TFHD track-id in-place during box construction.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| MediaStreamContext.cpp | Runs track-id parsing for audio media fragments and overwrites mismatched audio track-id. |
| isobmff/isobmffbuffer.cpp | Adds TFHD-based fallback for track-id extraction in fragmented MP4. |
| isobmff/isobmffbox.h | Extends TfhdBox API/state to track and rewrite TFHD track-id. |
| isobmff/isobmffbox.cpp | Implements TFHD track-id capture + optional overwrite during TFHD construction. |
Comments suppressed due to low confidence (2)
MediaStreamContext.cpp:233
- This INFO log now runs for every audio fragment (not just init), which can be very noisy; it also uses %d for a uint32_t track_id. Consider lowering to DEBUG and using correct format specifiers, and avoid setting mIsTrackIdMismatch for the overWriteTrackId (encrypted-header) use-case.
bool trackIdUpdated = false;
AAMPLOG_INFO("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);
}
MediaStreamContext.cpp:167
- This condition now includes eMEDIATYPE_AUDIO, so the subsequent track-id extraction runs for non-init audio fragments as well. In that path, IsoBmffBuffer::getTrack_id() can fail (it returns bool) but its return value is currently ignored, leaving track_id as 0 and potentially corrupting mCurrentAudioTrackId / overwrite behavior. Please guard the track-id logic when getTrack_id() returns false.
if ((actualType == eMEDIATYPE_INIT_VIDEO || actualType == eMEDIATYPE_INIT_AUDIO || actualType == eMEDIATYPE_AUDIO || actualType == eMEDIATYPE_INIT_SUBTITLE) && ret) // Only if init fragment successful or available from cache
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 | ||
| } | ||
| } |
There was a problem hiding this comment.
Keeping the try-catch block same as trak box construction
| TfhdBox* TfhdBox::constructTfhdBox(uint32_t sz, uint8_t *ptr, int newTrackId) | ||
| { | ||
| auto start = ptr; | ||
| uint8_t version = READ_VERSION(ptr); // 8 | ||
| uint32_t flags = READ_FLAGS(ptr); //24 | ||
|
|
||
| uint8_t* trackId_loc{ptr}; | ||
| uint32_t trackId = READ_U32(ptr); | ||
| if(-1 != newTrackId) | ||
| { | ||
| WRITE_U32(trackId_loc, static_cast<uint32_t>(newTrackId)); | ||
| trackId = static_cast<uint32_t>(newTrackId); | ||
| } |
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
-Removed unused headers -Removed unused tfhd track-id set function -Kept tfhd box const. consistent with existing trak box const. Signed-off-by: Abhi-jith-S <abhijithssa7@gmail.com>
|
Closing the PR as we are waiting for approval of fix |
Reason for change : To overwrite track-id for audio tracks incase of mismatch. Since the audio track mismatch caused audio loss while tile switching in mutliview streams
Test Procedure : Refer ticket