简体   繁体   中英

buffering issue with java communicating vlc

I'm a newbie to Socket communication, so I may be wrong, but please advice or at least give the direction!

I'm implementing an RTSP server according to http://www.csee.umbc.edu/~pmundur/courses/CMSC691C/lab5-kurose-ross.html#appendix taking a look to the similar code from http://www.java2s.com/Open-Source/Android/UnTagged/mynpr/com/webeclubbin/mynpr/RTSPserver.java.htm

At the moment I'm implementing responce to the OPTIONS request. To make it easy in the first approach, I decided to hardcode the answer according to the sample RTSP request/response log done for some real communication between vlc and gstreamer rtsp.

So, the log recorded with vlc URL -vvv says:

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

ie

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

part is 183 bytes length

I'm writing to the buffer right according to the example:

 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);
    }

and the vlc log says

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

Where CRLF is '\\n'. Before I tried CRLF="\\r\\n" (and no +"\\r"+ in the last line) with

Received 198 new bytes of response data.

So, what is wrong there? What vlc is waiting for? Why default delimeters from the example doesn't work for it?

I looks like I always find the answer to my questions after I publish them to stackoverflow...

DOUBLE CRLF should stand after the last header for the usual RTSP protocol 9not the customized one used in the example).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM