Search code examples
videovideo-streamingrtsprtprfc

What sequence number will an RTSP Announce have?


According to RFC2326, a server may send an ANNOUNCE message at any time, and the client must be prepared to answer.

However, it isn't clear which CSeq would the ANNOUNCE message have.

When I send a request with a method (be it PLAY, DESCRIBE, OPTIONS, etc), it has a cseq number, let's call it x. Can I trust that any message from the server, with cseq == x, will be a response to my message with sequence number x?

If not, then how can I realiably know that the message with same sequence number as mine, it actually a response to it?


Solution

  • According to 12.17 RFC2326 12.17 CSeq

    The CSeq field specifies the sequence number for an RTSP request-
       response pair. This field MUST be present in all requests and
       responses. For every RTSP request containing the given sequence
       number, there will be a corresponding response having the same
       number.
    

    The ANNOUNCE CSeq message from the server should be an increment from the previous message and you should response with CSeq from the server's ANNOUNCE CSeq.

    You can trust the server to respond with the same CSeq that you used in your PLAY, DESCRIBE, OPTIONS.

    If the server sends you an ANNOUNCE with the sequence number N then your OK response needs to have the sequence N in it. If you send a PLAY command after your OK - the PLAY would need N+1 as sequence number. For example:

    Server->Client:
    ANNOUNCE rtsp://192.168.1.2:554/foo RTSP/1.0
    CSeq: 42
    
    Client->Server:
    RTSP/1.0 200 OK
    CSeq: 42
    
    Client->Server:
    SETUP rtsp://192.168.1.2:554/foo/bar.foo RTSP/1.0
    CSeq: 43
    
    Server->Client:
    RTSP/1.0 200 OK
    CSeq: 43