Closed Bug 946110 Opened 6 years ago Closed 4 years ago

[B2G][WFD] Porting libstagefright_wfd to B2G


(Firefox OS Graveyard :: General, defect)

Gonk (Firefox OS)
Not set


(Not tracked)



(Reporter: ethan, Assigned: hchang)



(3 files, 1 obsolete file)

Bring frameworks/av/media/libstagefright/wifi-display/** in Gecko with some adaption.

Test method:
Run frameworks/av/media/libstagefright/wifi-display/wfd.cpp, providing the filename of a pre-recorded media file.

1. Connection Setup
   Verify RTSP session establishment.

2. RTP Streaming
   Use any local media file as media source or use frame buffer with the support of OMX encoder.
Blocks: 925615
Assignee: nobody → ettseng
Attached WIP. Compilable and linkable but not tested yet. 

It can also be found here:


to execute test file
Attached patch libstagefright_wfd (WIP) v2 (obsolete) — Splinter Review
1. Fixed HAVE_ANDROID_OS inconsistence issue.
2. Fixed broken android::StringPrintf caused by non-matched malloc/free.
3. Turned off gcc optimization for the debugging purpose.
4. Changed test binary name to TestWifiDisplay

Run TestWifiDisplay -l -f path/to/test_media
Hi Henry, it would be nice if you can post original Android source code or diff file here. It's easier for people to see the difference. :-)
Summary: [B2G][WFD] Porting libstagefright_wfd to Necko → [B2G][WFD] Porting libstagefright_wfd to B2G
Currently the library stagefright we ported from Android is located under Necko directory (network/protocol). The code location looks a little odd since libstagefright actually is not part of Necko.
The reason why we put it here is, this is just a temporary solution that we use libstagefright. We plan to rewrite/refactor the codes to create our own media playback engine and don't need to count on libstagefright.
Attached the original source files from aosp 4.3 frameworks/av/media/libstagefright/wifi-display.

Besides, you can also visit to see the difference.

Furthermore, visit to see the change based off of the original stagefright files.
Attached ported stagefright along with wifip2p. It works with my gaia remote 

You can also find my developing mozilla-central branch here:

To reproduce what I have done:

0) Get a nexus 4 and run B2G on it
1) Apply the attached patch onto your gecko or use the branch provided above.
2) Use my gaia remote (see above) and checkout to branch dev/wfd
3) $ ./ gecko && ./flash gecko
4) Added "ro.moz.wifi.p2p_supported=1" to your system/build.prop (Don't forget to change the permission to 644 if it makes your phone unable to boot)
5) $ adb remount && adb push mozilla-central/objdir-gecko-central/dist/bin/wfdservice  system/bin
6) Reboot
7) $ adb shell LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/system/b2g wfdservice
8) Settings --> Wifi Direct --> Connect to dongle

If you see something like the following in logcat, you are miracast-ing!

I/RTPSender(  846): lost 86.72 % of packets during report interval.
I/WifiDisplaySource(  846): onMessageReceived 5
I/WifiDisplaySource(  846): onMessageReceived 5
I/WifiDisplaySource(  846): onMessageReceived 5
I/WifiDisplaySource(  846): onMessageReceived 5
I/WifiDisplaySource(  846): onMessageReceived 5

You should have got an mVirtualDisplayBuffer in GonkDisplayJB


To remote display a local file:

(Branch off from step 5)

5) $ adb remount && adb push mozilla-central/objdir-gecko-central/dist/bin/TestWifiDisplay system/bin
6) $ adb shell LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/system/b2g TestWifiDisplay -l -f[file_path]
7) Settings --> Wifi Direct --> Connect to dongle

You should be watching the local file on the TV now!
Attachment #8356436 - Attachment is obsolete: true
By the way, you can find the modified ROM here to let some of nexus devices be the wifi display sink.
Assignee: ettseng → hchang
Great job, Henry!!
Apparently you are the owner of this bug now. :)
This is really a good starting point for the follow up development. Good job, Henry.
No longer blocks: 925615
Closed: 4 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.