Hi everybody,
Just a tech speak to share some info and testing-purpose-only patches.
A) Reasons / Motivation
Basically speaking, I wanted Netflix working on Android-x86. It would be cool if it worked.
I tried to check logs/add some debug cheks in order to discover why Netflix doesn't work on Android-x86 and fix that if I could... but I couldn't. However, I was able to do some mods in order to show some img and audio.
Img is messed up; Audio is ok. Subtitles also work. Crashes after a few seconds of play.
At first, I thought this could be related to the fact Netflix uses some arm libraries, which may contain calls somehow not supported by houdini. But this is not the case according to my conclusions (see bellow)
B) Some tech info about libstagefright / stagefright-plugins (warning: My conclusions - possibility of wrong assumptions)
Netflix makes use of libstagefright/statefright-plugins, which is working under Android-x86. Howver, it makes use of some resources that are not currently implemented, like:
=> getExtensionIndex method: Inside libstagefright, you can implement omx extensions for several purposes. Each extension has a unique constant number.
A plugin should implement this method in order to return the corresponding index for the omx string resource required.
As I could check on debugs, Netflix requires these:
- OMX.google.android.index.enableAndroidNativeBuffers
Gets/Sets a flag indicating native windows/gralloc buffers will be used
- OMX.google.android.index.getAndroidNativeBufferUsage
Gets/Sets usage flags passed to gralloc when allocating a buffer
- OMX.google.android.index.storeMetaDataInBuffers
Gets/Sets bStoreMetaData flag
- OMX.google.android.index.useAndroidNativeBuffer
- OMX.google.android.index.useAndroidNativeBuffer
Allocates a buffer
=> The implementation for omx extensions is done under internalGetParameter / internalSetParameter method. The ones mentioned above currently doesn't have a entry on these methods.
Also, we have some other issues that produces errors, avoiding the app to proper work. Here are some:
=> All over libstagefright/libstagefright-plugins code, there's some calls to checking macros (CHECK, CHECK_LT, etc). These are used to check if a value or condition is ok according to what is expected in that point. If not, these macros produces a crash, avoiding appto continue working.
They are necessary, no doubt of it. But some of them maybe are not. For instance, one of the reasons netflix crashed when playing a video was due this error:
F SoftFFmpegAudio: external/stagefright-plugins/libstagefright/codecs/ffmpegdec/adec/SoftFFmpegAudio.cpp:380 CHECK(isConfigured()) failed.
This check is on external/stagefright-plugins/libstagefright/codecs/ffmpegdec/adec/SoftFFmpegAudio.cpp, internalGetParameter, switch case "OMX_IndexParamAudioPcm" condition (an OMX extension).
Basically, it's a call to method isConfigured checking if mAudioSrcChannels atribute is not equal to "-1".
Currently, this check doesn't exists on Michael Chen github (at least the branches I checked).
I've ignored it (commented out) and had no audio problems (at least one I could identify) :)
=> Netflix uses gralloc for it's buffers. Using libstagefright/stagefright, it has some problems allocating the buffers:
- Color format is set with a OMX_COLOR constant value. These doesn't match HAL_PIXEL constants used by gralloc. When trying to alloc a buffer, gralloc complains it's not correct.
- Buffers allocated by stagefright doesn't seem to be locked/mapped. If you force a supported color format to alloc the buffer, it won't be able to write it. One point where this is done is under "sws_scale" call - This is a ffmpeg callback function responsible for converting/decoding contents.
C) Attempt to make it work:
Based on all the info above I created some patches (and after a few days of very boring sessions of "include debug info -> compile -> write flashdrive -> boot -> copy logcat -> boot again", of course :D ).
They produce a ISO were you can play something on netflix with a distorced img before it crashes. This is maximum my skills and knowledge allowed to.
I attached them here if anyone wants to take a look (4 patches - for external/mesa, external/stagefright-plugins, hardware/drm_gralloc and frameworks/av)
IMPORTANT NOTE: Color Format was changed from OMX_COLOR_FormatYUV420Planar to OMX_COLOR_Format32bitBGRA8888 (better support under drm_gralloc/mesa).
This breaks compatibility with other apps, non native buffers ones as I could check (embedded video player on Android default browser is one example)
If you want to play it just for fun, here's the ISO I built (not sure if this will work on Intel - Just tested on Radeon 7660D / Geforce 210, which uses gallium drivers):
I've made a short video showing netflix in action with this changes. output shows in 4 frames (maybe 320x240) and lacks color). Sound is good.
After a few seconds, it crashes.
D) Conclusion
I hope this info may be useful and that some skilled people nearby be kind of providing the necessary changes to include Netflix (and other streaming apps) support under Android-x86
ps: If Netflix had a option to avoid gralloc buffers, maybe it could work without any significant changes...