使用libcurl v7.43.0的Axis相机上的RTSP description返回RTSP错误码400

RTSP DESCRIBE on Axis Camera with libcurl v7.43.0 returns RTSP errorcode 400

本文关键字:RTSP 返回 description 错误 误码 相机 v7 libcurl Axis 使用      更新时间:2023-10-16

我得到一个HTTP错误400响应以下RTSP URL正在处理的函数如下所示。

description rtsp://root:pass@192.168.1.47/axis-media/media.amp ?videocodec=h264/

我使用的IP摄像机是最新的AXIS H264摄像机。

我使用的libcurl版本是v7.43.0

bool CHttpClientCurl: Get (){//初始化curlCURLcode res = CURLE_OK;if (m_curl == NULL){m_sError = L"CURL句柄为NULL ";返回错误;}

m_sBuffer.clear();
// initialize this curl session
curl_easy_reset(m_curl);
char sUrl[8192];
wcstombs(sUrl, m_sUrl.c_str(), m_sUrl.length());
sUrl[m_sUrl.length()] = '';
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
printf("    cURL V%s loadedn", data->version);
if (m_curl != NULL) {
    curl_easy_setopt(m_curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(m_curl, CURLOPT_NOPROGRESS, 1L);
    curl_easy_setopt(m_curl, CURLOPT_PROTOCOLS, CURLPROTO_RTSP);
    res = curl_easy_setopt(m_curl, CURLOPT_URL, sUrl); 

    // request server options
    printf("nRTSP: OPTIONS %sn", sUrl);
    curl_easy_setopt(m_curl, CURLOPT_PROTOCOLS, CURLPROTO_RTSP);
    res = curl_easy_setopt(m_curl, CURLOPT_RTSP_STREAM_URI, sUrl); 
    curl_easy_setopt(m_curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); 
    curl_easy_setopt(m_curl, CURLOPT_RTSP_TRANSPORT, "RTP/AVP;unicast;client_port=64378-64379");
//  curl_easy_setopt(m_curl, CURLOPT_RTSP_SESSION_ID, "56789");
    res = curl_easy_perform(m_curl);
    int64_t nHttpCode = 0;
    curl_easy_getinfo(m_curl, CURLINFO_RESPONSE_CODE, &nHttpCode);
    m_nStatusCode = nHttpCode;
    if (res != CURLE_OK)
    {
        std::wstringstream ss;
        ss << curl_easy_strerror(res);
        m_sError = L"Error occurred - " + std::wstring(ss.str());
        return false;
    }
    else if (nHttpCode != 200)
    {
        SetErrorString(nHttpCode);
        return false;
    }
}
return true;

}

有人能告诉我,如果有一个错误在URL或在c++函数?

解决这个问题的方法是首先在rtsp字符串中提供用户凭据,然后连续两次发出rtsp DESCRIBE。如果用户凭证不正确或丢失,第一个RTSP DESCRIBE请求将导致HTTP 401错误码。第二个DESCRIBE请求将产生一个HTTP 200 OK代码。在第二个RTSP描述返回HTTP 200 OK之后,你可以发出一个RTSP SETUP请求,然后是一个RTSP PLAY请求,它应该返回HTTP 200并创建RTSP流。