Wednesday, November 6, 2013

Android 4.3 wfd command line(Wi-fi Display/ Miracast )

Below are steps  the steps to run wfd source and sink from android 4.3 command line.
PATH of wi-fi display on android is "frameworks/av/media/libstagefright/wifi-display" after build it creates libstagefright_wfd.so library and wfd binary
1) Android 4.3 wfd contains only source, sink code is available on MR2 merge the sink code from MR2 to MR3.
2) In Sink code replace ISurfaceTexture to IGraphicBufferProducer to fix compilation issue.
3)Merge wfd.cpp to for  sink changes.
4)OnDisplayConnected of wfd.cpp make the width and height according to the device resolution.

void RemoteDisplayClient::onDisplayConnected{
 .......
 SurfaceComposerClient::openGlobalTransaction();
       mComposerClient->setDisplaySurface(mDisplayBinder, mSurfaceTexture);
      mComposerClient->setDisplayLayerStack(mDisplayBinder, 0)  ;

        Rect layerStackRect(width, height); 
        Rect displayRect(2560,1600);// make the resolution change according to the display this is manta resolution
    mComposerClient->setDisplayProjection(
                mDisplayBinder, 0 /* 0 degree rotation */,
                displayRect,
                layerStackRect);
  ......

}

1. Connect two Android >= 4.3 devices to Wi-Fi network.

2. Execute Source

Connect your device to PC via usb(adb).
$ adb shell netcfg
wlan0    UP    192.168.1.2/24  0x00001043 12:34:56:78:90:ab   <-- your device IP address.

$ adb shell wfd -l 192.168.1.2:20000
listen

3. Execute Sink

Connect another device to PC via usb(adb).
$ adb shell netcfg
wlan0    UP    192.168.1.3/24  0x00001043 ab:90:78:56:34:12   <-- your device IP address.

$ adb shell wfd -c 192.168.1.2:20000  <-- Source device IP Address != your device IP address
connect to source