1

I have to develop an app that will stream RTP video stream from a server and play it on my android device. I also have to create a rtp server on another android device from which this client app will stream video.

But, what i found is that Rtp stream is hard to play directly(without RTSP). How can I implement such a player in android/java.

I am aware of Vitamio but i doubt if it can play rtp.

Please correct me if i am wrong and i really could use some help.

Ana
  • 841
  • 10
  • 28

3 Answers3

1

you can use URI package to read the video stream, please try playing RTSP video stream like this:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final VideoView vidView = (VideoView)findViewById(R.id.myVideo);
    MediaController vidControl = new MediaController(this);
    vidControl.setAnchorView(vidView);
    vidView.setMediaController(vidControl);
    vidView.setVideoPath("rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov");
    vidView.start();
 }
Albert Chen
  • 1,331
  • 1
  • 12
  • 13
0

The MediaPlayer class can play RTSP directly, so you don't have to develop a client. For the server, either implement RTSP or use some library that does. If you don't need to support many simultaneous clients, it's relatively easy to do.

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84
  • 1
    sir i need to implement RTP player. I want to avoid RTSP wrapper. Can i do so in android. – Ana Apr 11 '14 at 08:54
  • can you suggest me some library for implementing RTSP server? Please , it will be a great help. – Ana Apr 11 '14 at 09:08
  • 1
    You can serve a static SDP file, no need for RTSP. – Nikolay Elenkov Apr 11 '14 at 09:38
  • I have to stream live video from one device to another over available wifi network without using internet. Can SDP help?If so, please can you provide me some guideline from where to start. – Ana Apr 11 '14 at 09:43
  • 1
    Start with reading :) The SDP is just a description, it shows where the actual RTP stream is and what the format is. You still need somewhat to generate that stream. You can do the encoding with MediaCodec, but still have to write the code to produce RTP packets. So either find the RTP RFC and implement an RTP packetizer, or find some library that does it for you. I think there is at least one in pure Java. You could use Gstreamer, which has everything you need, but it's a bit more complicated, since it requires native code. – Nikolay Elenkov Apr 11 '14 at 13:18
0

Another option is to use ExoPlayer. Actually current official version of ExoPlayer doesn't support RTSP/RTP. But as indicated in the issue issue 55 there's an active pull request #3854 to add this support.

In the meantime, you can clone the original authors exoplayer fork which does support RTSP (branch dev-v2-rtsp):

git clone -b dev-v2-rtsp https://github.com/tresvecesseis/ExoPlayer.git.

I've tested it and it works perfectly. The authors are working actively to fix the issues reported by many users and I hope that RTSP/RTP support at some point becomes part of the official exoplayer.

rkachach
  • 16,517
  • 6
  • 42
  • 66