Setting up an Android emulator for testing TV apps

This is a pretty basic overview on how to setup the Android TV emulator to sort of work like a TV device if you are testing a UI.

First we are going to assume that you want to emulate basic controls like on a simple remote e.g. with up/down/left/right, back and menu. Emulating a more advanced remote will be the subject of a more detailed post.

First you are going to need Android Developer Tools installed. And then you need to open the Android Virtual Device Manager.

Steps to achieve this setup are as per the following video:

Essentially what we are doing here is:

  1. Creating an essentially blank AVD based on a 4.2.2 operating system image
  2. Setting it so the hardware dpad is enabled, as this is what we will use for basic remote emulation
  3. Setting it so that the hardware keys (menu, back) are enabled

Details of my config.ini are here:

avd.ini.encoding=ISO-8859-1
abi.type=armeabi-v7a
disk.dataPartition.size=200M
hw.accelerometer=yes
hw.audioInput=yes
hw.battery=yes
hw.camera.back=none
hw.camera.front=none
hw.cpu.arch=arm
hw.cpu.model=cortex-a8
hw.dPad=yes
hw.device.hash2=MD5:6930e145748b87e87d3f40cabd140a41
hw.device.manufacturer=Generic
hw.device.name=4.65in 720p (Galaxy Nexus)
hw.gps=yes
hw.keyboard=yes
hw.lcd.density=320
hw.mainKeys=yes
hw.ramSize=1024
hw.sdCard=no
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images/android-14/armeabi-v7a/
skin.dynamic=yes
skin.name=1280x720
skin.path=1280x720
tag.display=Default
tag.id=default
vm.heapSize=64

Accessing a network service on the device can be done with a bit of extra setup. The following example shows how we would access a service running over http on the emulator on port 6999

  1. Telnet to the port of the device, e.g. telnet localhost 5554
  2. Type: redir add tcp:5010:6999
  3. You can now access http://localhost:5010/remote the same as if it was running on the device that was available on the local network

DVB-T2 playback on Android

There are now a number of devices on the market that include a tuner in an Android device, which is not surprising as Android is basically linux however exposing the bitstream up through the Android stack is a bit trickier than in linux as standard libs that people would use such as V4L are not present.

In our testing the Amlogic SoC stack and open linux platform provide a good basis for this and they have also made available a good reference library for implementing the DVB protocols (T2 and S2 for now).

Will be posting more on this topic soon but for now here is a demo of DVB-T2 working off an Android device and captured via my desktop.

Playing HEVC/H.265 on Android with ffmpeg, libx265 and Vitamio

After testing out quite a few other peoples attempts at building and using ffmpeg on Android I settled on the Vitamio build (again as have done the same process before) as it offers the best mix of features and also has a reasonably active community (even if I have to use translate from Chinese!).

First download the latest builds of Vitamio-FfmpegVitamioBundle and OpenSSL-Vitamio (Use git clone for these).

Download and install the latest Android NDK

Note that I run OSX so these tips are for that though should be near identical for linux.

Change into the directory for OpenSSL-Vitamio and run ndk-build

cd OpenSSL-Vitamio
/path/to/ndk/ndk-build

Now we need to make sure that environment variables are available to support our build for the build_android script and then run the build script

export SSL=/path/to/OpenSSL-Vitamio
export ANDROID_NDK=/path/to/ndkinstall
./build_android.sh

For some reason my build was failing for arm7 due to linking of the ssl libs, to fix this I had to remove the –enable-openssl from the ffmpeg setup options in build_android.sh