在 Android 上播放实时 RTP 流
我正在尝试在 android 上构建一个客户端,它将接收 RTP 流并播放它。 我在 stackoverflow 和 Google 上搜索过,发现 MediaPlayer 类可以用于此目的。但是当使用 URL 或文件作为数据源时,会使用 MediaPlayer。 在我的场景中,我的流媒体服务器在客户端的特定端口上发送 RTP 流。 那么,有没有办法让MediaPlayer播放这个流而不需要将其写入文件。
I am trying to build a client on android that will receive RTP streams and play it.
I have searched on stackoverflow and Google, and found that MediaPlayer class can be used for this. But the MediaPlayer is used when a URL or a file is used as data source.
In my scenario, my streaming server send RTP streams on a particular port of my client.
So, is there any way to play MediaPlayer to play this stream without writing it into a file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你尝试过吗?
MediaPLayer 的“数据源”是 rtsp 链接 - rtsp://127.0.0.0:550/mystream.3gp
我已经使用 VideoView 完成了此操作,MediaPlayer 只是对此的抽象,因此它不应该有太大不同。
MedaiPlayer 将解析 rtsp url 并启动 Android RTSPEngine,它将与 RTP 服务器通信并建立相关端口来传输数据。
Have you tried it out?
Your 'data source' for MediaPLayer is your rtsp link - rtsp://127.0.0.0:550/mystream.3gp
I have done this with a VideoView, MediaPlayer is jsut an abstraction of this, so it shouldn't be too different.
The MedaiPlayer will parse the rtsp url and start the Android RTSPEngine which will communicate with the RTP Server an establish the relevants ports to transfer the data.
上述方法有效 - 您需要提供 rtsp 链接(您可能不需要该端口,因为 RTSP 默认为端口 554,而不是 550)。
rtsp://se.rv.er.ip/mystream
本质上,RTSP 对话发生在客户端和服务器之间(描述、设置、播放),其中将包含 RTP 广播的 .sdp 文件所具有的信息。
除非发送 RTP 流的服务器支持 RTSP,否则您无法接收 RTP 流。
如果您需要更多详细信息,我建议您在流媒体客户端或服务器上运行wireshark。我发现这有助于补充阅读 RFC。
祝你好运!
The method described above works - you need to supply the rtsp link (you likely won't need the port since RTSP defaults to port 554, not 550).
rtsp://se.rv.er.ip/mystream
Essentially an RTSP conversation occurs between the client and server (DESCRIBE, SETUP, PLAY) which will contain the information a .sdp file for an RTP broadcast would have.
You cannot receive an RTP stream unless the server sending it supports RTSP.
If you need more details, I'd recommend just running wireshark on a streaming client or server. I found that helped supplement reading the RFCs.
Good luck!