2013-09-10 36 views
0

我是Socket通信的新手,所以我可能是错的,但请指教或至少给出方向!与java沟通vlc的缓冲问题

我根据http://www.csee.umbc.edu/~pmundur/courses/CMSC691C/lab5-kurose-ross.html#appendix实现RTSP服务器考虑看看到类似的代码从http://www.java2s.com/Open-Source/Android/UnTagged/mynpr/com/webeclubbin/mynpr/RTSPserver.java.htm

在我实施性反应的OPTIONS请求的时刻。为了使第一种方法更容易,我决定根据针对vlc和gstreamer rtsp之间的某些实际通信所做的示例RTSP请求/响应日志对答案进行硬编码。

所以,记录VLC URL日志-vvv说:

Sending request: OPTIONS rtsp://localhost:8554/test RTSP/1.0 
CSeq: 2 
User-Agent: LibVLC/2.0.8 (LIVE555 Streaming Media v2013.04.30) 


Received 183 new bytes of response data. 
Received a complete OPTIONS response: 
RTSP/1.0 200 OK 
CSeq: 2 
Public: OPTIONS, DESCRIBE, GET_PARAMETER, PAUSE, PLAY, SETUP, SET_PARAMETER, TEARDOWN 
Server: GStreamer RTSP server 
Date: Tue, 10 Sep 2013 19:56:53 GMT 


Sending request: DESCRIBE rtsp://localhost:8554/test RTSP/1.0 
CSeq: 3 
User-Agent: LibVLC/2.0.8 (LIVE555 Streaming Media v2013.04.30) 
Accept: application/sdp 

RTSP/1.0 200 OK 
CSeq: 2 
Public: OPTIONS, DESCRIBE, GET_PARAMETER, PAUSE, PLAY, SETUP, SET_PARAMETER, TEARDOWN 
Server: GStreamer RTSP server 
Date: Tue, 10 Sep 2013 19:56:53 GMT 

部分是183个字节长度

我写信是为了根据缓冲区权示例:

try{ 
     System.out.println("S -> C"); 
     System.out.println("RTSP/1.0 200 OK"); 
     System.out.println("CSeq: "+RTSPSeqNb); 
     //System.out.println("Session: "+RTSP_ID); 
     if (responceType==OPTIONS) {System.out.println("Public: OPTIONS, DESCRIBE, GET_PARAMETER, PAUSE, PLAY, SETUP, SET_PARAMETER, TEARDOWN");}; 
     if (responceType==OPTIONS) {System.out.println("Server: GStreamer RTSP server");              }; 
     if (responceType==OPTIONS) {System.out.println("Date: Tue, 10 Sep 2013 19:56:53 GMT");}; 
     RTSPBufferedWriter.write("RTSP/1.0 200 OK"+CRLF); 
     RTSPBufferedWriter.write("CSeq: "+RTSPSeqNb+CRLF); 
     //RTSPBufferedWriter.write("Session: "+RTSP_ID+CRLF); 
     if (responceType==OPTIONS) {RTSPBufferedWriter.write("Public: OPTIONS, DESCRIBE, GET_PARAMETER, PAUSE, PLAY, SETUP, SET_PARAMETER, TEARDOWN"+CRLF);}; 
     if (responceType==OPTIONS) {RTSPBufferedWriter.write("Server: GStreamer RTSP server"+CRLF);              }; 
     if (responceType==OPTIONS) {RTSPBufferedWriter.write("Date: Tue, 10 Sep 2013 19:56:53 GMT"+CRLF);   }; 
     RTSPBufferedWriter.write("Session: "+RTSP_ID+"\r"+CRLF); 
     RTSPBufferedWriter.flush(); 

     //RTSPBufferedWriter.newLine(); 
     System.out.println("RTSP Server - Sent response to Client."); 

    } 
    catch(IOException ex) 
    { 
     System.out.println("Exception caught: "+ex.getStackTrace()); 
     // System.exit(0); 
    } 

和vlc日志说

Opening connection to 127.0.0.1, port 6666... 
...remote connection opened 
Sending request: OPTIONS rtsp://127.0.0.1:6666/autostream.mjpg RTSP/1.0 
CSeq: 2 
User-Agent: LibVLC/2.0.8 (LIVE555 Streaming Media v2013.04.30) 


Received 193 new bytes of response data. 
[0x7fd01c001178] live555 demux debug: connection timeout 
[0x7fd01c001178] live555 demux error: Failed to connect with rtsp://127.0.0.1:6666/autostream.mjpg 

其中CRLF是'\ n'。之前我试过CRLF = “\ r \ n”(没有+ “\ r” +在最后一行)与

Received 198 new bytes of response data. 

那么,什么是错的呢?什么vlc正在等待?为什么示例中的默认delimeters不起作用?

回答

0

我看起来像我总能找到答案我的问题后,我把它们发布到计算器...

对于通常RTSP协议9not示例中使用自定义的一个最后一个头之后

双CRLF应该站) 。