While experimenting with the excellent IP Webcam video server for Android, I found that the standard web browser and programs like VLC were intolerant of disconnects of the WiFi. Each time it disconnected, it would require manual intervention to reconnect, so I started looking at what it would take to make a very simple viewer in my Java client program.
It turns out to be relatively easy, though there is plenty of room for improvement. I found that even on my little netbook, I could get smooth video at 320x200 from the Android server just by repeatedly pulling down a static JPG from the IP Webcam and shoving each image into a simple extended JContainer. I expected it to be jerky, but it worked surprisingly well.
Note: I first tried a JLabel, which is the simplest way to load a picture in Java that I'm aware of. It was VERY slow. Not recommended. :-)
While it would likely be a bit faster to read the MJPEG stream it can provide, this was much easier to get working, and should be fine for what I want to do with it.
Once I had it working in a test program, I added a dedicated thread to my client program to handle the video connection and display. So now the client program consists of a GUI thread, a data/command thread, and a video thread.
The video thread launches and goes into a nested loop. The outer loop is keyed to a flag that gets set when the user requests a connection to the robot. The inner loop grabs the images from the Android server. If the connection drops or an image retrieval error occurs, it breaks out of the inner loop, resets and continues retrying until the user requests a disconnect. As a result, like the command/sensor thread, it automatically reconnects after the WiFi connects back up, and resumes the video feed.
The handling of the loss of the network connection has been consistently the hardest part of this so far, but that nested loop approach has worked well in both threads to automatically re-establish the connection.