Android 中的 RTSP 客户端
我正在 Android 中编写 RTSP 客户端。 我能够收到所有请求的回复 即,
- DESCRIBE它用传输发回200 OK
- SETUP:RTP/AVP:unicast:client_port=4568:4569收到200 OK消息返回
- 发送PLAY,并收到OK消息
之后如何获取音频和视频帧?
我在博客上搜索过,但都说要在 client_port 上监听,但我没有收到任何数据包。
请让我知道我做得是否正确。
I am writing a RTSP client in Android. I am able to receive the Responses for all the requests
i.e.,
- DESCRIBE it sends back the 200 OK
- SETUP with transport: RTP/AVP:unicast:client_port=4568:4569 got the 200 OK Message back
- Sent PLAY, and got the OK Message
After that how to get the audio and video frames?
I have searched on blogs, but all say to listen at client_port but I am not receiving any packets.
Please let me know am I doing correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可能知道也可能不知道这一点,Android 已经内置了对使用 VideoView 的 RTSP 支持。
http://developer.android.com/reference/android/widget/VideoView。 html
这可能会减少您的开发时间...或者如果您尝试推出自己的 RTSP 堆栈,它可能完全没用。
You may or may not know this, but Android has built in support for RTSP using the VideoView.
http://developer.android.com/reference/android/widget/VideoView.html
This may cut down on your development time...or it may be totally useless if you're trying to roll your own RTSP stack.
RTSP 仅用于启动流媒体。 它为您提供真实流的 SDP 描述。 您必须管理每个通道(音频/视频)的 RTCP 连接和 RTP 连接。 要使用的端口是“client_port”端口。
从头开始编写 RTSP/RTCP/RTP 堆栈非常复杂。 您可以查看在 C++ 中实现此类堆栈的 live555 库。
RTSP is only used to start the streaming. It gives you an SDP description of the real streams. You have to manage an RTCP connection and a RTP connection per channel (audio / video). The ports to use are the "client_port" ones.
It is pretty complex to code a RTSP/RTCP/RTP stack from scratch. You can have a look at the live555 library that implement such a stack in c++.
在网络上放置一个嗅探器,您应该会看到目标端口为 4568 的 UDP 数据包,目标是您的 IP 地址。
使用像样的嗅探器,您将能够看到 rtsp 对话框。 也许您在答案中遗漏了一些内容
您还应该检查 SETUP 响应的内容,以查看您请求的端口是否被接受。
要检查的事情:
如果您位于路由器或防火墙后面,您可能不会收到任何内容,因为您的路由器/防火墙不知道如何处理传入的 UDP 数据包
Put a sniffer on the network, you should see UDP packet with destination port 4568 targeted at your IP address.
With a decent sniffer, you will be able to see the rtsp dialog. Maybe you are missing something in the answers
You should also check the content of the SETUP response, to see if the port you requested were accepted.
Things to check :
If you are behind a router or firewall, you probably won't receive anything, because your router / firewall don't know what to do with incoming UDP packets
首先尝试在 LAN 内安装本地 Darwin 流媒体服务器。这样防火墙就不再重要。流媒体将正常工作。
如果您想从外部服务器尝试,则:
1) 检查 SERVER 响应中提到的 client_ports,某些服务器建议的端口与请求的端口不同。您必须使用服务器建议的端口。
2)如果端口正确,那么您可以从每个UDP端口向服务器发送64字节的空数据包(称为“开门器”)。
3) 如果以上两种方法都不能解决问题,请检查服务器端日志。服务器可能正在关闭 UDP 端口。
Try first with a local Darwin Streaming server installed within your LAN.that way Firewall wont matter.Streaming will work.
If you want to try from external server then:
1) Check the client_ports mentioned in the SERVER response,some servers suggest different ports from the one requested.you have to use the ports suggested by server.
2) If the ports are correct, then you can send 64byte empty packets from each of the UDP ports to the server(called "door openers").
3) If the above two don't fix it, check the server side logs.The server might be closing the UDP ports.