gpt4 book ai didi

java - 无法从 RTSP 服务器获得任何答复

转载 作者:搜寻专家 更新时间:2023-11-01 02:50:42 28 4
gpt4 key购买 nike

我可以使用预制软件连接到我的 Rtsp 服务器,但是使用以下代码我无法从服务器获得答案。即使连接成功,服务器也没有回答我。

public class RtspClient {

private Socket server;
private InputStream is = null;
private OutputStream os = null;
private int seqid = 1;
private String request, resp;
private byte[] buffer = new byte[4096];
private int len = 0;


public RtspClient(String rIp, int rPort) {

try {
//INIT
server = new Socket(rIp, rPort);
is = server.getInputStream();
os = server.getOutputStream();
System.out.println("Connected to "+ rIp + ":" + rPort);

//COMMUNICATION
Boolean isTalking = true;
while(isTalking == true) {

//sending request
String request = new String("OPTIONS * RTSP/1.0\r\nCSeq: 0\r\n");
os.write(request.getBytes(), 0, request.length());
System.out.println("Sent: "+ request);
/////////////////

//getting response
len = is.read(buffer, 0, buffer.length);

if(len > 0) {
resp= new String(buffer, 0, len);
}
else {
resp = "empty";
}

System.out.println("Received: "+ resp);
//////////////////
}
} catch (UnknownHostException e ) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

这是 wireshark 的屏幕截图:http://imageplay.net/img/tya22277766/Untitled.png

服务器的回答应该是:

RTSP/1.0 200 OK
Supported: play.basic, con.persistent
Cseq: 0
Server: Wowza Media Server x.x.x.x buildxxx
Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, OPTIONS, ANNOUNCE, RECORD, GET_PARAMETER
Cache-Control: no-cache

谢谢!

最佳答案

好吧,简而言之,请求应该是:

OPTIONS * RTSP/1.0\r\nCSeq: 0\r\n\r\n

代替

OPTIONS * RTSP/1.0\r\nCSeq: 0\r\n\

只需在末尾添加一个新行,服务器就会回答

关于java - 无法从 RTSP 服务器获得任何答复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11748083/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com