I have developed a little application that can play video from a rstp streaming sever (darwin in this case, but this is not relevant) by means of the VideoView widget (I have tried Mplayer+SurfaceView approach too). I use Wifi connection for this.
The video plays just smooth when video is the only task. The small application should carry out other tasks at the same time such as continously discover bluetooth devices and call a remote web service (I am using Ksoap2 for this). When these background taks run at the same time as the video playback the performance incredibly drops (the image and sounds sometimes stop and image gets distorted, showing rather big squares instead of proper frames).
This happens even with low quality videos (3gp at 50 kbps). For the bluetooth discovery I have used both available methods with no performance enhancement over each other:
- Using discovery way provided by SDK 5 and register every found bluetooth device.
- Using a native call to a self written scan() method that takes advantage of
hci_inquiry()
function provided by Bluez API.
The call to WS requieres the bluetooth adressess of the discovered devices. The call comes after the discovery has finished.
I tried to use a GLSurfaceView instead of SurfaceView, but as I am rather new to Android platform, and have no 3D graphic programming mileage, I could not make it work, since I could not find any example of how to use OpenGL ES propertly to playback video and still being able to let Android API control other UI related stuff (Dialogs/Menus/Toasts). On the other hand I do not know if this could indeed improve the playback.
Any clues or tips of the way I could take?
Edit: I forgot to say that I am developing on a Motorola Milestone
Edit 2: Following CommonsWare and snctln suggestions I tried to minimize memory footprint of application while not completely leaving out SOAP WS calls.
Now I try to cache as many objects as possible and only execute call when new BT devices are found (WS need discovered BT devices as input) to minimize GC calls. Video still plays awfully only with Bluetooth discovering active (no WS calls at all).
Edit 3: Solution: I modified my application to use UMTS (3G) data connection instead of Wifi when scanning bluetooth devices. Though device accesses public Internet (m.youtube.com) it plays streaming video far smoother over 3G (from public Internet servers) than over local Wifi (from local streaming server). Local streaming server performance is not an issue since streaming to desktop PCs just runs fine. I also upgraded device firmware to 2.0.1 and also experienced some improvement with local Wifi connection, but 3G playback performance still beats Wifi.
My conclusion is that this device must have some conflicting hardware (maybe same chipset) or software issues when using simultaneous Wifi/Bluetooth communication.