curl-library
Issue while writing a RTSP client
Date: Thu, 29 Jul 2010 12:30:32 +0530
Hi,
i am writing a RTSP client program. I am using live555 as a RTSP server.
When i am sending a SETUP request the i am getting a response with code 400
(Bad request). Can anyone help me with this, the code looks like this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream){
printf("Size is: %d\n",size);
printf("Nmemb is: %d\n",nmemb);
return size*nmemb;
}
int main(int argc, char *argv[])
{
CURL *csession;
CURLcode res;
struct curl_slist *custom_msg = NULL;
char URL[256];
char request[256];
long rc;
int port = 48000;
FILE * protofile = NULL;
protofile = fopen("Dump","wb");
if (argc < 2)
{
fprintf (stderr, "ERROR: enter a valid URL\n");
return -1;
}
csession = curl_easy_init();
if (csession == NULL)
return -1;
printf("%s\n", argv[1]);
sprintf (URL, "%s", argv[1]);
curl_easy_setopt(csession, CURLOPT_URL, URL);
curl_easy_setopt(csession, CURLOPT_RTSP_STREAM_URI, URL);
curl_easy_setopt(csession, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(csession, CURLOPT_HEADER, 1);
curl_easy_setopt(csession, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
curl_easy_setopt(csession, CURLOPT_INTERLEAVEDATA, protofile);
//curl_easy_setopt(csession, CURLOPT_VERBOSE, 1);
/** retrieve OPTIONS */
curl_easy_setopt(csession, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
res = curl_easy_perform(csession);
res = curl_easy_getinfo(csession, CURLINFO_RESPONSE_CODE, &rc);
if((res == CURLE_OK) && rc)
{
fprintf(stderr, "OPTIONS Response Code: %ld\n\n", rc);
}
else
return -1;
/** send DESCRIBE */
custom_msg = curl_slist_append(custom_msg, "Accept: application/x-rtsp-mh,
application/rtsl, application/sdp");
curl_easy_setopt(csession, CURLOPT_RTSPHEADER, custom_msg);
curl_easy_setopt(csession, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
res = curl_easy_perform(csession);
res = curl_easy_getinfo(csession, CURLINFO_RESPONSE_CODE, &rc);
if((res == CURLE_OK) && rc)
{
fprintf(stderr, "DESCRIBE Response Code: %ld\n\n", rc);
}
else
return -1;
/** send SETUP */
sprintf (request, "RTP/AVP;unicast;client_port=%
d", port);
curl_easy_setopt(csession, CURLOPT_RTSP_TRANSPORT, request);
curl_easy_setopt(csession, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
res = curl_easy_perform(csession);
res = curl_easy_getinfo(csession, CURLINFO_RESPONSE_CODE, &rc);
if((res == CURLE_OK) && rc)
{
fprintf(stderr, "SETUP Response Code: %ld\n\n", rc);
}
else
return -1;
/** send PLAY */
curl_easy_setopt(csession, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
res = curl_easy_perform(csession);
res = curl_easy_getinfo(csession, CURLINFO_RESPONSE_CODE, &rc);
if((res == CURLE_OK) && rc)
{
fprintf(stderr, "PLAY Response Code: %ld\n\n", rc);
}
else
return -1;
/** send GET_PARAMETER */
/*curl_easy_setopt(csession, CURLOPT_RTSP_REQUEST,
CURL_RTSPREQ_GET_PARAMETER);
res = curl_easy_perform(csession);
res = curl_easy_getinfo(csession, CURLINFO_RESPONSE_CODE, &rc);
if((res == CURLE_OK && rc))
{
fprintf(stderr, "GET_PARAMETER Response Code: %ld\n\n", rc);
}
else
return -1;
*/
/** send TEARDOWN */
curl_easy_setopt(csession, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN);
res = curl_easy_perform(csession);
res = curl_easy_getinfo(csession, CURLINFO_RESPONSE_CODE, &rc);
if((res == CURLE_OK) && rc)
{
fprintf(stderr, "TEARDOWN Response Code: %ld\n\n", rc);
}
else
return -1;
curl_easy_cleanup(csession);
fclose(protofile);
return 0;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-07-29