Detection of supported audio encoders on Android to prevent crashes "This audio encoder 2 not found"

When the Android device does not support the required audio encoder, you get: (X = encoder numerical index)

E / MediaProfiles (4048): this audio encoder X was not found A / AudioSource (4048): frameworks / base / media / libstagefright / AudioSource.cpp: 58 CHECK (channels == 1 || channels == 2) failed. A / libc (4048): fatal signal 11 (SIGSEGV) at 0xdeadbaad (code = 1) In native code. No exception to respond. The application is simply forcibly closed.

Is there a way to request an Android device> 3.x if AAC AMR-NB and AMR-WB are actually supported? The documentation ( http://developer.android.com/guide/appendix/media-formats.html ) says that they are the main media formats and therefore are always supported. Some actual and widespread phones out there (major brands) do not.

MediaCodec.createByCodecName(String name) and Get supported codec for an Android device only works with API16 = Android 4.1, but the devices in question are 4.0.x. Nor does it list AMR-NB and AAC.

+4
source share
1 answer

On your Android device, media profiles / features are stored in the media_profiles.xml configuration file (on ICS / 4.0).

Usually this file is located in the / etc folder on the device.

So what you can do is

  • Connect your device to the computer and pull the / etc / media _profiles.xml file using the adb pull command
  • Explore the properties of AudioEncoderCap. Multiple entries will be announced for each advertised advertisement. for ex:

    AudioEncoderCap name = "aac" enabled = "true" minBitRate = "8192" maxBitRate = "96000" minSampleRate = "8000" maxSampleRate = "16000" minChannels = "1" maxChannels = "1"

  • If the "enabled" flag is set to "true", as indicated above, this function must be supported by the device. If it is not supported, the "enabled" flag will be set to "false".

AFAIK, the media codec infrastructure introduced in jb (4.1), reads this / similar configuration file to reveal the capabilities of the device at the application level.

Hope this helps.

Thanks!

+2
source

Source: https://habr.com/ru/post/1445457/


All Articles