Checking netflix crashes (libstagefright/stagefright-plugins testing changes)

798 views
Skip to first unread message

pstglia

unread,
Mar 28, 2015, 5:56:42 PM3/28/15
to andro...@googlegroups.com
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...



frameworks_av_0001-NETFLIX-HACK-Disables-CHECK-macro-functions-and-forc.patch
hardware_drm_gralloc_0001-HACK-Threat-OMX_COLOR-formats-BGRA8888-and-YUV420Pla.patch
external_mesa_0001-NETFLIX-HACK-Threats-OMX_COLOR-format-constants-YUV4.patch
external_stagefright_plugins_0001-NETFLIX-HACK-Includes-some-OMX-extensions-and-disabl.patch

pstglia

unread,
Mar 28, 2015, 6:00:21 PM3/28/15
to andro...@googlegroups.com

Mauro Rossi

unread,
Mar 31, 2015, 8:15:31 AM3/31/15
to andro...@googlegroups.com
Hi Paulo,

Nice job, you let there be light.
Congrats

I'm keeping up with my debugging self-training and launching the test app Grafika by Google, I have noticed that omx based on stagefright is missing some h264 tags/implementation forma both encoding and decoding.

Could this be one of the reasons mp4 video can't be played, even with android native player?

M.

pstglia

unread,
Mar 31, 2015, 9:11:04 AM3/31/15
to andro...@googlegroups.com
Hi Mauro, 


Em terça-feira, 31 de março de 2015 09:15:31 UTC-3, Mauro Rossi escreveu:
Hi Paulo,

Nice job, you let there be light.
Congrats
 
Thanks. Just trying to pull the trigger for someone else do the real job (like you are doing on Mesa currently). 


I'm keeping up with my debugging self-training and launching the test app Grafika by Google, I have noticed that omx based on stagefright is missing some h264 tags/implementation forma both encoding and decoding.

Could this be one of the reasons mp4 video can't be played, even with android native player?

It's possible (to be honest, I've never tried to open an mp4 video on Android-x86). In case of Netflix, the lack of 3 extensions pointed above are the main reasons it avoided even trying to open a video.

Ps: Mesa has an omx state tracker. Is it stable? Could be used here somehow?

Chih-Wei Huang

unread,
Apr 1, 2015, 4:19:33 AM4/1/15
to Android-x86
Good to see you make some progress.
However, I'm afraid it's not possible to make it work
so you are just wasting the time.

As I know Netflix or similar apps use DRM to protect
the contents. Android uses Widevine DRM Framework
to decode the protected contents.
It requires a Widevine plugin and a keybox that
only available for commercial android products.
It's not a part of AOSP.

The android-x86 doesn't have any of the stuff.
So I don't think we have a chance to decode it.

Refer https://source.android.com/devices/drm.html

Of course I may be wrong...
> --
> You received this message because you are subscribed to the Google Groups
> "Android-x86" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-x86...@googlegroups.com.
> To post to this group, send email to andro...@googlegroups.com.
> Visit this group at http://groups.google.com/group/android-x86.
> For more options, visit https://groups.google.com/d/optout.



--
Chih-Wei
Android-x86 project
http://www.android-x86.org
Reply all
Reply to author
Forward
0 new messages