我使用libcurl来做RTSP请求。我设置了卷曲选项,如下所示:
FILE *tmpListDownloadFile;
tmpListDownloadFile = fopen(tmp.c_str(), "w");
if(tmpListDownloadFile != NULL)
{
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
char *p = curl_easy_unescape(curl, UriP, 0, NULL);
string s = p;
curl_free(p);
string uri = url + "/?" + s;
printf("%s uri:%s\n",__FUNCTION__,uri.c_str());
curl_version_info_data *d = curl_version_info(CURLVERSION_NOW);
printf("curl version:%s\n",d->version);
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, uri.c_str());
curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, stRtspInfo.CSeq);
curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, transport.c_str());
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_SETUP);
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)tmpListDownloadFile);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 15);
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_NONE);
CURLcode curlResult = curl_easy_perform(curl);
char* session_id;
if(curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &session_id) == CURLE_OK)
{
printf("%s session_id:%s\n",__FUNCTION__, session_id);
if(NULL != session_id)
{
ostringstream ss;
ss << session_id;
stRtspInfo.sessionID = ss.str();
bIsSessionEstablished = true;
}
}
else
{
printf("%s getting session id failed\n",__FUNCTION__);
}
curl_easy_cleanup(curl);
curl_global_cleanup();
fclose(tmpListDownloadFile);
if (curlResult == CURLE_OK && bIsSessionEstablished == true)
{
...
}
else
{
printf("Setup failed\n");
}
}
日志信息如下。
RtspSetup url:rtsp://10.134.158.71
RtspSetup transport:RTP/AVP;unicast;client_port=45636-45637
RtspSetup uri:rtsp://10.134.158.71/?src=1&freq=11054&sr=30000&pol=v&msys=dvbs2&mtype=8psk&fec=34&ro=0.35&plts=off&pids=0
curl version:7.21.3
* About to connect() to 10.134.158.71 port 554 (#0)
* Trying 10.134.158.71... * connected
* Connected to 10.134.158.71 (10.134.158.71) port 554 (#0)
> SETUP rtsp://10.134.158.71/?src=1&freq=11054&sr=30000&pol=v&msys=dvbs2&mtype=8psk&fec=34&ro=0.35&plts=off&pids=0 RTSP/1.0
CSeq: 1
Transport: RTP/AVP;unicast;client_port=45636-45637
If-Modified-Since: Thu, 01 Jan 1970 00:00:00 GMT
* HTTP 1.1 or later with persistent connection, pipelining supported
< RTSP/1.0 200 OK
< CSeq: 1
< Date: Sat, Jan 01 2000 00:14:11 GMT
< Transport: RTP/AVP;unicast;destination=10.134.158.14;source=10.134.158.71;client_port=45636-45637;server_port=6970-6971
< Session: E3C33231;timeout=60
< com.ses.streamID: 3
<
* Connection #0 to host 10.134.158.71 left intact
RtspSetup session_id:E3C33231
Altough我将Timecondition设置为none,if-modified-since被添加到标头中。我想删除if-modified-since标头。怎么做?