You can create a socket, take it's "file descriptor", and give that to the MediaPlayer.setDataSource()
.
I have actually done something similiar to this a while back, so this approach is tested in the field.
I forget exactly how to extract the file descriptor from a socket, but I think that using reflection - or more likely native code - you can get an 'impl
' member on the socket which is a LocalSocket or something, and has a 'fd
' member. Googling has not found anyone describing this, so you'll have to explore the exact member names and details yourself.
The container format will have to be something that is recognised by the Android system; if necessary you can use native code to create a pipe so that you can repackage your custom container into something that Android supports on-the-fly using a thread.
It occurs to me that there's a good chance that Android plays 'raw' H.263 and H.264BP or whatever, but I have not tested this. AVI is obviously not ideal for streaming - you might have to split your video up into short chunks of AVI, and keep swapping these blocks - or you might explore if FLV or Matroska is supported, but be cautious - the exact mix of supported container formats might differ from device to device, or from release to release.