Playing sdp file (rtsp stream) from http u

2020-07-24 03:47发布

I have a rtsp stream on my rtsp server in localhost. I would to play this file with the android class MediaPlayer.

If I do setDataSource(rtsp://localhost/file.sdp) it works!!

My problem is... if I copy the file on my http server and I do

setDataSource(http://localhost/file.sdp) 

it does not work!! I receive an I/O exception.

filePath = "http://localhost/file.sdp";
mediaPlayer.setDataSource(filePath);
mediaPlayer.prepare();
mediaPlayer.start();

If I play this file with vlc application it works.

2条回答
混吃等死
2楼-- · 2020-07-24 04:29

RTSP "Real Time Streaming Protocol" is for streaming media server. You can watch live video broadcasting from remote server on your computer/mobile device through RTSP protocol. This protocol only handle playback of media files. Below are some features of RTSP:

  1. This works on TCP connection
  2. RTSP requests are all sent on the same TCP connection
  3. This protocol has very less end-to-end delay
  4. This is also called "true streaming"
  5. No file is downloaded to user's system
  6. Play movie in real time
  7. Can do live broadcast
  8. Some firewall blocks this protocol on user's machine

HTTP "Hypertext Transfer Protocol" is for transferring files (text, graphic images, sound, video, and other multimedia files) on the World Wide Web. HTTP protocol communicate between Web pages (Contain text, graphic images, sound, video and other multimedia) hosted on remote server and the user's browsers on their system. We can watch streaming video through HTTP protocol. Below are some features of HTTP:

  1. This works on TCP connection
  2. HTTP will typically send each request on a separate TCP
  3. This protocol has high end-to-end delay as compared to RTSP
  4. Serve content from standard web server
  5. This support progressive download from a web server
  6. File is downloaded to user's system but can start playing before completely downloaded
  7. This works on all firewall because it uses standard HTTP protocol

SDP "Session Description Protocol" consists of a set of communications end points along with a series of interactions among them. SDP contains information about streaming media. It contains mainly three parts about media - Session description, Time description and Media description. SDP not itself is a file type but it is a protocol and responsible for steaming media. HTTP and RTSP both support SDP.

查看更多
一夜七次
3楼-- · 2020-07-24 04:36

RTSP and HTTP are different protocols. An HTTP server is not going to serve the data in the same way. It's going to send HTTP headers, etc. VLC may be somehow smart enough to infer the protocol based on the data it receives, but Android's NuPlayer is probably not so sophisticated.

查看更多
登录 后发表回答