android中的RTSP客户端
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1201374/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
RTSP client in android
提问by Vinay
I am writing a RTSP client in Android. I am able to receive the Responses for all the requests i.e.,
我正在用 Android 编写一个 RTSP 客户端。我能够收到所有请求的响应,即,
- 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
- DESCRIBE 它发回 200 OK
- SETUP with transport: RTP/AVP:unicast:client_port=4568:4569 got the 200 OK Message back
- 发送 PLAY,并收到 OK 消息
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.
我在博客上搜索过,但都说要在 client_port 上收听,但我没有收到任何数据包。
Please let me know am I doing correctly.
请让我知道我做得是否正确。
回答by haseman
You may or may not know this, but Android has built in support for RTSP using the VideoView.
您可能知道也可能不知道,但 Android 已经使用 VideoView 内置了对 RTSP 的支持。
http://developer.android.com/reference/android/widget/VideoView.html
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 堆栈,它可能完全没用。
回答by neuro
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.
RTSP 仅用于启动流式传输。它为您提供了真实流的 SDP 描述。您必须管理每个通道(音频/视频)的 RTCP 连接和 RTP 连接。要使用的端口是“client_port”端口。
It is pretty complex to code a RTSP/RTCP/RTP stack from scratch. You can have a look at the live555library that implement such a stack in c++.
从头开始编写 RTSP/RTCP/RTP 堆栈非常复杂。您可以查看在 c++ 中实现此类堆栈的live555库。
回答by shodanex
Put a sniffer on the network, you should see UDP packet with destination port 4568 targeted at your IP address.
在网络上放置一个嗅探器,您应该会看到目标端口为 4568 的 UDP 数据包以您的 IP 地址为目标。
With a decent sniffer, you will be able to see the rtsp dialog. Maybe you are missing something in the answers
使用合适的嗅探器,您将能够看到 rtsp 对话框。也许你在答案中遗漏了一些东西
You should also check the content of the SETUP response, to see if the port you requested were accepted.
您还应该检查 SETUP 响应的内容,以查看您请求的端口是否被接受。
Things to check :
检查事项:
- Listening in UDP.
- Firewall rules.
- Range of the play request : Don't specify any to be sure the server will be playing something.
- 监听UDP。
- 防火墙规则。
- 播放请求的范围:不要指定任何内容以确保服务器将播放某些内容。
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
如果你在路由器或防火墙后面,你可能不会收到任何东西,因为你的路由器/防火墙不知道如何处理传入的 UDP 数据包
回答by Shreesh
Try first with a local Darwin Streaming server installed within your LAN.that way Firewall wont matter.Streaming will work.
首先尝试在您的 LAN 中安装本地 Darwin 流服务器。这样防火墙就无所谓了。流将工作。
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.
1) 检查 SERVER 响应中提到的 client_ports,有些服务器建议的端口与请求的端口不同。您必须使用服务器建议的端口。
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").
2) 如果端口正确,那么您可以从每个 UDP 端口向服务器发送 64 字节的空包(称为“开门器”)。
3) If the above two don't fix it, check the server side logs.The server might be closing the UDP ports.
3)如果以上两个都没有解决,请检查服务器端日志。服务器可能正在关闭UDP端口。