Skip to content
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

Add AC-4 Level-4 ISO base media file format support #1265

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ybai001
Copy link
Contributor

@ybai001 ybai001 commented Apr 11, 2024

This pull request is same as #875. Since 875 is broken due to too many commit numbers, I re-created this new one.

========================

AC-4 Level-4 (Object Based Audio) is a Dolby official audio stream type for Atmos Music. This code update enables Android Media3 support local MP4 and MPEG-DASH AC-4 Level-4 playback.

// Using first presentation (default presentation) channel count
int presentationIndex = 0;
Ac4Presentation ac4Presentation =
Objects.requireNonNull(ac4Presentations.get(presentationIndex));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ybai001,

Why are we looping over all presentationIndex above and storing it in a Map when all we require is the ac4Presentation for the index 0?

Is it to verify if the file doesn't have bad data? Even in that case storing it in a Map seems an overkill, when we don't intend to use the map for anything else but index 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohitjoins,
This AC4 parser implementation is similar as the one in Android Framework: https://cs.android.com/android/platform/superproject/main/+/main:frameworks/av/media/module/extractors/mp4/AC4Parser.cpp;drc=2e87c835abea90b0cf61b42dc9aa8a882f2ef5aa;l=292. It parses all the information for all presentations because there is API https://developer.android.com/reference/android/media/MediaExtractor#getAudioPresentations(int) to fetch the presentations info for appointed audio track.

Since AndroidX Media extractor doesn't support AudioPresentation, I know this loop is redundant now.

But I know Android framework MPEGExtractor was deprecated and it will be replaced by AndroidX Media extractor. Although AndroidX Media doesn't support AudioPresentation now but I believe it will support it sooner or later. That's why I use a Map to store all audio presentation info and keep this logic in my implementation.

If one audio track includes multiple audio presentations, and if application doesn't set which presentation should be played, the Dolby AC-4 decoder will decode the default presentation (the first presentation).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ybai001,

I would suggest to remove any logic which will be used in the future as it can be added when required. For now we should only parse and use the first presentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohitjoins , OK, I'll update the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohitjoins, I have updated the code as your suggestion.

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.

None yet

2 participants