title: Using cURL and rtsp
body: <p>Using cURL, I get this error</p>
  
  <pre><code>$ ./rtspclient.o rtsp://192.168.1.5:554/streamingVideos_10/Movie8minMedium.mov 2000 0 10
  rtsp://192.168.1.5:554/streamingVideos_10/Movie8minMedium.mov
  * Protocol rtsp not supported or disabled in libcurl
  * Unsupported protocol
  </code></pre>
  
  <p>According to the <a href="http://curl.haxx.se/docs/faq.html#Protocol_xxx_not_supported_or_di" rel="nofollow">manual</a>, that happens due to typos! however, that doesn't apply to my case. </p>
  
  <p>More information:</p>
  
  <p>I have successfully installed cURL as below</p>
  
  <pre><code>mkdir curlinst
  ./configure --prefix=/path/to/curldirectory/curlinst/ --enable-rtsp
  make
  make install
  </code></pre>
  
  <p>Using code rtspclientfinal.c :</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  #include &lt;curl/curl.h&gt;
  
  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 temp_URL[256];
    char request[256];
    long rc;
    int port = 48000;
    FILE * protofile = NULL;
    protofile = fopen("Dump","wb");
    if (argc &lt; 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]);
    port = atoi(argv[2]);
    int timeoutend = atoi(argv[3]);
  
    timeoutend *= 30; //timeoutend holds the correct number of seconds the stream is expected to last
  
    curl_easy_setopt(csession, CURLOPT_URL, URL);
    curl_easy_setopt(csession, CURLOPT_RTSP_STREAM_URI, URL);
    curl_easy_setopt(csession, CURLOPT_HEADER, 1);
  
    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, &amp;rc);
    if((res == CURLE_OK) &amp;&amp; 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, &amp;rc);
    if((res == CURLE_OK) &amp;&amp; rc)
    {
        fprintf(stderr, "DESCRIBE Response Code: %ld\n\n", rc);
    }
    else
        return -1;
  
    /** send SETUP */
    sprintf(temp_URL, "%s/trackID=3", URL);
    printf("%s\n",temp_URL);
    curl_easy_setopt(csession, CURLOPT_RTSP_STREAM_URI, temp_URL);
    sprintf (request, "RTP/AVP/UDP;unicast;client_port=%d-%d", port,port+1);
    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, &amp;rc);
  
    if((res == CURLE_OK) &amp;&amp; rc)
    {
        fprintf(stderr, "SETUP Response Code: %ld\n\n", rc);
    }
    else
        return -1;
  
    sprintf(temp_URL, "%s/trackID=4", URL);
    printf("%s\n",temp_URL);
    curl_easy_setopt(csession, CURLOPT_RTSP_STREAM_URI, temp_URL);
    sprintf (request, "RTP/AVP/UDP;unicast;client_port=%d-%d", port,port+1);
    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, &amp;rc);
  
    if((res == CURLE_OK) &amp;&amp; rc)
    {
        fprintf(stderr, "SETUP Response Code: %ld\n\n", rc);
    }
    else
        return -1;
  
  
    /** send PLAY */
    curl_easy_setopt(csession, CURLOPT_RTSP_STREAM_URI, URL);
    curl_easy_setopt(csession, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
    fprintf(stderr, "playing...\n\n");
    res = curl_easy_perform(csession);
  
    if(res != CURLE_OK)
    {
        fprintf(stderr, "PLAY failed: %d (%s)\n\n", res, curl_easy_strerror(res));
        return -1;
    } else {
        res = curl_easy_getinfo(csession, CURLINFO_RESPONSE_CODE, &amp;rc);
        fprintf(stderr, "PLAY Response Code: %ld\n\n", rc);
    }
  
  
    sleep(timeoutend);
  
    /** 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, &amp;rc);
    if((res == CURLE_OK) &amp;&amp; rc)
    {
        fprintf(stderr, "TEARDOWN Response Code: %ld\n\n", rc);
    }
    else
        return -1;
  
    curl_easy_cleanup(csession);
  
    return 0;
  }
  </code></pre>
  
  <p>Then I compile rtspclientfinal.c with the following command </p>
  
  <pre><code>gcc -I /path/to/curl/curlinst/include -L /path/to/curl/curlinst/lib/ -lcurl rtspclientfinal.c -o rtspclient.o
  </code></pre>
  
  <p>Without any error.</p>