/// Parse a given RTSP URL and return Service::RTSP, Service::LockedRTSP or
/// an error.
Parse a given RTSP URL and return Service::RTSP, Service::LockedRTSP or
an error.
Parse a given RTSP URL and return Service :: RTSP Service :: LockedRTSP or an error .
fn parse_rtsp_url(url: &str) -> Result<Service, RuntimeError> {
    let res = r"^rtsp://([^/]+@)?([^/@:]+|\[[0-9a-fA-F:.]+\])(:(\d+))?(/.*)?$";
    let re  = Regex::new(res).unwrap();
    if let Some(caps) = re.captures(url) {
        let host = caps.at(2).unwrap();
        let path = caps.at(5).unwrap();
        let port = match caps.at(4) {
            Some(port_str) => u16::from_str(port_str).unwrap(),
            _ => 554
        };
        let socket_addr = try!(net::utils::get_socket_address((host, port))
            .or(Err(RuntimeError::from(
                "unable to resolve RTSP service address"))));
        let mac = get_fake_mac_address(0xffff, &socket_addr);
        // note: we do not want to probe the service here as it might not be
        // available on app startup
        match caps.at(1) {
            Some(_) => Ok(Service::LockedRTSP(mac, socket_addr)),
            None    => Ok(Service::RTSP(mac, socket_addr, path.to_string()))
        }
    } else {
        Err(RuntimeError::from("invalid RTSP URL given"))
    }
}
fn parse_rtsp_url ( url : & str ) -> Result < Service , RuntimeError > { let res = r"^rtsp://([^/]+@)?([^/@:]+|\[[0-9a-fA-F:.]+\])(:(\d+))?(/.*)?$" ; let re = Regex :: new ( res ) . unwrap ( ) ; if let Some ( caps ) = re . captures ( url ) { let host = caps . at ( 2 ) . unwrap ( ) ; let path = caps . at ( 5 ) . unwrap ( ) ; let port = match caps . at ( 4 ) { Some ( port_str ) => u16 :: from_str ( port_str ) . unwrap ( ) , _ => 554 } ; let socket_addr = try ! ( net utils get_socket_address ( ( host port ) ) or ( Err ( RuntimeError from ( " " ) ) ) ) ; let mac = get_fake_mac_address ( 0xffff , & socket_addr ) ; // note: we do not want to probe the service here as it might not be // available on app startup match caps . at ( 1 ) { Some ( _ ) => Ok ( Service :: LockedRTSP ( mac , socket_addr ) ) , None => Ok ( Service :: RTSP ( mac , socket_addr , path . to_string ( ) ) ) } } else { Err ( RuntimeError :: from ( " " ) ) } }
Parse a given RTSP URL and return Service::RTSP, Service::LockedRTSP or
an error.
Parse a given RTSP URL and return Service :: RTSP Service :: LockedRTSP or an error .
url
&str