Forum Discussion

Kirk_Bauer_1018's avatar
Kirk_Bauer_1018
Icon for Nimbostratus rankNimbostratus
Jul 20, 2007

How to tell when a RTSP request completes?

My knowledge of RTSP is very limited so maybe I'm not asking this properly. But it seems I can watch for the event RTSP_REQUEST to see when a new RTSP session is started. Does that session typically request just one video (accessible via RTSP::uri)? How do I tell when that video is done playing and/or that request is finished?

 

 

I want to be able to track the number of active RTSP streams per-URI. Something like this (using the persistence table to track data with timeouts):

 

 

when RULE_INIT {

 

array set ::uri_count { }

 

}

 

 

when RTSP_REQUEST {

 

set uri [RTSP::uri]

 

if { [ info exists ::uri_count($uri) ] } {

 

incr ::uri_count($uri)

 

} else {

 

set ::uri_count($uri) 1

 

}

 

}

 

 

when ?????????? {

 

if { [ info exists ::uri_count($uri) ] } {

 

decr ::uri_count($uri)

 

if { $uri_count($uri) <= 0 } {

 

unset ::uri_count($uri)

 

}

 

}

 

}

 

 

I just don't know how to detect when the request is finished... can anybody help?
  • Brandon_Burns_8's avatar
    Brandon_Burns_8
    Historic F5 Account
    Kirk,

     

     

    Is this limiting done on a per uri basis, or a per streaming server? It would be easier to limit the number of streams on a given server using the following rule.

     

     

    when RULE_INIT {

     

     

    array set connections { }

     

     

    }

     

     

     

     

    when CLIENT_ACCEPTED {

     

     

    if { [info exists ::connections([IP::local_addr])] } {

     

     

    if { [incr ::connections([IP::local_addr])] > 1000 } {

     

     

    reject

     

     

    }

     

     

    } else {

     

     

    set ::connections([IP::local_addr]) 1

     

     

    }

     

     

    }

     

     

     

     

    when CLIENT_CLOSED {

     

     

    if { [incr ::connections([IP::local_addr]) -1] <= 0 } {

     

     

    unset ::connections([IP::local_addr])

     

     

    }

     

     

    }
  • Unfortunately per-URI. They want URI persistence but want to limit the maximum number of connections for one URI on one server.
  • Does anybody know how the events are chained and in which order? For example, if I do this:

     

     

    when RTSP_REQUEST {

     

    set uri [RTSP::uri]

     

    }

     

     

    Can I later reference $uri in LB_SELECTED, SERVER_CONNECT, and SERVER_CLOSED? Anybody know of a easy way to test RTSP (i.e. a server out there I can point to)?
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Yes, you can reference the variable in any subsequent event for the life of the connection.

     

     

    /deb