I am trying to develop a Streaming AV Media Server for use with an Android handset as the client. This instantly puts a constraint on me to develop a server that uses RTSP. I am versed in Java programming and have found that Netty (Java NIO) can be used to fill in the otherwise massive gap in the Java Media Framework for this protocol. I have played around with it and have had no real success. I know about live555 but I’m on a tight schedule and don't really want to start messing around with C++ as I know very little on the subject. I have been stuck on this problem for many weeks and have nothing really to show for it. Streaming to android must be possible as there are numerous proprietary apps on the Android market. Could someone who has experience and knowledge on this subject please let me know if there is a simple way to implement an RTSP AV media server that just streams .mp4 or .3gp and .mp3 for use with android without using the live555 libraries. If not I will just have to quickly get up to speed on C++. Thank you in advance.
3
votes
@user673090: I don't understand this statement..."This instantly puts a constraint on me to develop a server that uses RTSP"...why are you constrained to using RTSP? I can create a virtual directory in IIS pointing to my music folder on my PC and with no more than a few lines of code stream mp3 files over a wi-fi connection using HTTP to my Android device. OK, I'm not suggesting it's what you call a 'robust' AV server solution but it certainly doesn't require RTSP. Expand on why you need RTSP and what it has to do with Android specifically.
– Squonk
Hi, thanks for responding. I have really been struggling with the RTSP transfer to Android. The reason this conclusion has been drawn and is relative to Android is beacuse if RTP is to be used over a transport protocol it has to use RTSP. Now I am aware that HTTP can also be used to stream (progressivly) and this is quickly becoming a better option. Can you please elaborate on how and what you use to stream your music via HTTP to your handset. Thank you.
– user673090
@user673090: OK, I understand the link between RTP and RTSP but I still don't understand what would make you think that streaming to an Android device would need RTP. Give me 10 minutes and I'll post some code to demonstrate my HTTP example.
– Squonk
@user673090: Thinking about it, I understand why you want to use RTP/RTSP...for seek control etc. Right? RTP/RTSP is huge - I've got the RFCs printed out somewhere in a stack of paper in the corner and I'm not sure I'd want to implement it from scratch. Anyway, simple progressive HTTP streaming code posted in my answer.
– Squonk
3 Answers
2
votes
OK, simple as this to stream using HTTP.
I created a virtual folder called 'Music' with IIS on WinXP and pointed it at a folder containing mp3 files. This is the complete Activity needed to stream a file (name hard-coded).
BTW, it's called SimpleNetRadio as I originally started playing around with Shoutcast streams.
package com.mycompany.SimpleNetRadio;
import android.app.Activity;
import android.media.AsyncPlayer;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
public class SimpleNetRadio extends Activity
{
private AsyncPlayer ap = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected void onStart() {
super.onStart();
ap = (AsyncPlayer) getLastNonConfigurationInstance();
}
@Override
protected void onStop() {
super.onStop();
if (ap != null)
ap.stop();
}
@Override
protected void onResume() {
super.onResume();
if (ap == null) {
ap = new AsyncPlayer("Simple Player");
ap.play(this, Uri.parse("http://192.168.1.1/Music/02%20-%20Don't%20Stop%20Believin'.mp3"), true, AudioManager.STREAM_MUSIC);
}
}
@Override
public Object onRetainNonConfigurationInstance() {
return ap;
}
}
You should also be able to do this with MediaPlayer with a bit more code - it would handle error conditions better and wouldn't require much more work.
1
votes
0
votes
I'm not sure what your specific needs are, but for static files you might try combining Amazon S3 and CloudFront, which I believe supports RTSP.