FORUMS
Remove All Ads from XDA
H10 Turbo

[Application] gstreamer for Eclair, Froyo and Gingerbread

24 posts
Thanks Meter: 19
 
By s7mx1, Junior Member on 27th February 2011, 05:06 PM
Post Reply Email Thread
Here it is the gstreamer for your rooted android phones. I have made two flashable zip files:

gstreamer-0.10_gingerbread.signed.zip for android 2.3 (gingerbread)
gstreamer-0.10_24-11-10.signed.zip for android 2.1 and 2.2 (eclair, froyo)

I strongly suggest you take a backup of system partition before you flash as it contains third party shared objects like glib and oil.

For your convenience I have included a init script at /etc/init.d/99rtpstream which will launch either "/system/sd/rtpstream.sh" (eclair and froyo) or "/sd-ext/rtpstream.sh" (gingerbread) if they exists at boot time.

Gstreamer is a very flexible multimedia frameworks and it supports windows, OpenBSD and Linux. More information can be found in http://gstreamer.freedesktop.org.
This build is targeted at audio processing as I could not get the videooutput (surfaceflingersink) working. Patches are welcome please see the bottom of the post for sources.

Turns your mobile into wifi speakers

At home I have a htpc which plays videos on the TV. However occasionally I would like to use my android mobile as wifi speakers with a pair of headphones so I will not disturb others. This setup also give me the freedom to roam around the whole house whilst listening to favorite music/radio or just anything being played on the htpc. I found it rather convenient to listening to online radios.


Step 1 On your android mobile
Login to your mobile either via adb or ssh and run the following commands in sequence:
Code:
export GST_PLUGIN_PATH=/system/plugins
export GST_REGISTRY_UPDATE=1
export GST_REGISTRY=/system/sd/gst-reg.bin
AUDIO_CAPS="application/x-rtp, media=(string)audio, clock-rate=(int)90000, encoding-name=(string)MPA, channels=(int)2,rate=(int)44100, payload=(int)96,  endianness=(int)1234"
gst-launch-0.10 udpsrc buffer-size=4096 port=6500  !  $AUDIO_CAPS ! rtpmpadepay ! mad ! audioconvert !  audioflingersink sync=false latency-time=100 blocksize=16384
Replace "/system/sd/" by the correct place where your sd card is being mounted, for aoss build this is likely to be "/sd-ext/".

Step 2 On your pc
Here are instructions for windows and linux only, for other platforms please refer for online help to setup correct source and parameters.

{windows}
Install gstreamer 0.10.7 from http://code.google.com/p/ossbuild/do...a03-0.10.7.msi
and run the following command from the console
Code:
cd "C:\Program Files (x86)\OSSBuild\GStreamer\v0.10.7\bin
gst-launch.exe directsoundsrc blocksize=4096 ! audioconvert ! lamemp3enc target=1 cbr=true bitrate=128 ! rtpmpapay ! udpsink port=6500 host=ANDROID_PHONE_IP
Replace ANDROID_PHONE_IP by the ip address of your android mobile

{Linux}
Code:
gst-launch-0.10 pulsesrc device=output.monitor ! "audio/x-raw-int,channels=2,rate=44100" ! audioconvert ! lamemp3enc target=1 cbr=true bitrate=128 ! rtpmpapay ! udpsink port=6500 host=ANDROID_PHONE_IP
Replace "ANDROID_PHONE_IP" by the ip address of your android mobile and replace "output.monitor" by the name of your default pulseaudio output monitor device.

Automate the process

If you are happy with the whole thing, I would suggest put the script from Step 1 into /etc/init.d/ so it will start automatically at boot time. However you will not be able to start/stop gstreamer easily without touching the adb or ssh console. I ended up adding a loop to check a particular file on sdcard with the following script (save it to /etc/init.d/ as 99rtpstream.sh and make it executable)
Code:
#!/system/bin/sh
export GST_PLUGIN_PATH=/system/plugins
export GST_REGISTRY_UPDATE=1
export GST_REGISTRY=/system/sd/gst-reg.bin
AUDIO_CAPS="application/x-rtp, media=(string)audio, clock-rate=(int)90000, encoding-name=(string)MPA, channels=(int)2,rate=(int)44100, payload=(int)96,  endianness=(int)1234"

killall gst-launch-0.10  > /dev/null 2>&1

while [ "$test" = "" ]; do
if [ -f /system/sd/rtpstream.nostart ]; then
sleep 5 
else
gst-launch-0.10 udpsrc buffer-size=4096 port=6500  !  $AUDIO_CAPS ! rtpmpadepay ! mad ! audioconvert !  audioflingersink sync=false latency-time=100 blocksize=16384
sleep 5
fi
done
Replace "/system/sd/" by the correct place where your sd card is being mounted, for aoss build this is likely to be "/sd-ext/".

Basically it will not start gstreamer if there is a file called rtpstream.nostart on sd card.

I have also created 2 scripts on sdcard that can be used with gscript lite so I can start/stop gstreamer from gscript without touching adb or console.

start script (save it to sdcard as rtpstream-start.sh and make it executable)
Code:
#!/system/bin/sh
rm /system/sd/rtpstream.nostart
Replace "/system/sd/" by the correct place where your sd card is being mounted, for aoss build this is likely to be "/sd-ext/".


stop script (save it to sdcard as rtpstream-stop.sh and make it executable)
Code:
#!/system/bin/sh
busybox ps | grep gst-launch | grep -v grep | awk '{print $1}' | xargs kill
touch /system/sd/rtpstream.nostart
Replace "/system/sd/" by the correct place where your sd card is being mounted, for aoss build this is likely to be "/sd-ext/".

In gscript you can create 2 scripts with root permission and one to use the start script and the other to use stop script.


Other considerations
Streaming realtime udp over wifi when screen is switched off proved to be problematic (voice chopping) under android as most of the factory wifi driver is too aggressive on power saving. The solution is to change the default power saving mode to something like PM_FAST for some broadcom chips. This will involve recompiling the kernel. If you are using wildfire/buzz you can try my customised kernel from here http://forum.xda-developers.com/showthread.php?t=967746.

Sources
Most of the gestreamer sources including dependency libs come from http://github.com/prajnashi/ and it was ported for andriod 1.5 and as such the gstreamer android plugin is not working at all and I had to resort to this http://github.com/jahrome/. Unfortunately I could not get the video sink (surfaceflingersink) working, patches are welcome.
 
 
Post Reply Subscribe to Thread

Tags
eclair, froyo, gingerbread, gstreamer

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes