RTSP Client in Android
The same question might have been asked but I didn't find any solutions available for me.
I'm trying to play RTSP stream in android and the server is Darwin streaming server. For now I’ve tried VideoView and MediaPlayer, both of which always work fine when I use 3G but have problems when I use Wifi sometimes, specifically when I use Wifi at my workplace, and the error in LogCat:
PlayerDriver( 31): buffering (0)
I have googled around a开发者_JAVA技巧nd guess the reason maybe the Wifi hotspot is behind the firewall and the UDP port is blocked, and the Opencore media framework only supports RTP over UDP. Correct me if I am wrong.
Then, here is my question, how can I solve it if i cannot change the firewall situation. If using the build-in VideoView/MediaPlayer is not possible, then how to write my own rtsp client.
Any suggestion will be appreciated:)
Thanks in advance!
Bolton
I don't think that you can do much with this... Heres my idea:
Make an app that will be started in the same LAN as Darvin, then it will get Darvin's RTP stream which goes over UDP (in LAN) and then transmit that over TCP to WAN, so you can access it. You can easily write that app in C#... and it will work perfectly. Or if you have some Linux distro, you can write a complex Bash script that will use NC to do the same...
So this is basically the idea:
Using the MediaPlayer is recommended way to go with RTSP. but as you said that the problem persist with the WiFi firewall, in such case you have to have enable the ports or configure the needful. I think there is no solution for this as the problem is with network not your code. So the ball is not in your court.
Its quite easy and interesting task in android.
Just Follow the instructions.
1- Install VLC on your computer (SERVER) and go to Media->Streaming (Ctrl+S) 2- select a file to stream or if you want to stream your webcam or... click on "Capture Device" tab and do the configuration and finally click on "Stream" button. 3- here you should do the streaming server configuration, just go to "Option" tab and past the following command:
:sout=#transcode{vcodec=mp4v,vb=400,fps=10,width=176,height=144,acodec=mp4a,ab=32,channels =1,samplerate=22050}:rtp{sdp=rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/}
NOTE: replace YOURCOMPUTER_SERVER_IP_ADDR with your computer IP address or any server which is running VLC...
NOTE: You can see, the video codec is MP4V which is supported by android.
4- go to eclipse and create a new project for media playbak. create a VideoView object and in the OnCreate() function write some code like this:
mVideoView = (VideoView) findViewById(R.id.surface_view);
mVideoView.setVideoPath("rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/");
mVideoView.setMediaController(new MediaController(this));
5- run the apk on the device (not simulator, i did not check it) and wait for the playback to be started. please consider the buffering process will take about 10 seconds...
精彩评论