兩個rtsp流,設為rtsp1,rtsp2:
1. 使用前判斷rtsp1,是否可用.如果不可用就用rtsp2,反之用rtsp1.
求判斷的方法,急.

解决方案 »

  1.   

    //# curl_apply_userpwd --start
    $url = "http://203.90.252.78:8086/connectioncounts";
    $user = "***";
    $pass = "***";
    echo curl_apply_userpwd($url, $user, $pass);

    /*  # Get the page with userpwd  
    * $url->page url, 
    * $user->user name, 
    * $pass->password
    */
    function curl_apply_userpwd($url, $user, $pass) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_TIMEOUT, 15); 
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
    $return = curl_exec($ch);
    if (!$return) {
    $error = url_error($ch);
    curl_close($ch);
    return $error;
    }else {
    curl_close($ch);
    return $return;
    }
    }
    以php模擬登入獲得流的服務器信息,就很容易判斷了