2015-04-15 90 views
0

使用捲曲,我得到這個錯誤捲曲和RTSP

$ ./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 

按照manual,即由於錯別字發生!然而,這不適用於我的情況。

的更多信息:

我已經成功地安裝捲曲如下

mkdir curlinst 
./configure --prefix=/path/to/curldirectory/curlinst/ --enable-rtsp 
make 
make install 

使用代碼rtspclientfinal.c:

#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 temp_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]); 
    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, &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(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, &rc); 

    if((res == CURLE_OK) && 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, &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_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, &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, &rc); 
    if((res == CURLE_OK) && rc) 
    { 
     fprintf(stderr, "TEARDOWN Response Code: %ld\n\n", rc); 
    } 
    else 
     return -1; 

    curl_easy_cleanup(csession); 

    return 0; 
} 

然後我編譯rtspclientfinal.c用下面的命令

gcc -I /path/to/curl/curlinst/include -L /path/to/curl/curlinst/lib/ -lcurl rtspclientfinal.c -o rtspclient.o 

沒有任何錯誤。

回答

0

我想你正在使用你的系統的共享庫libcurl而不是你建立的那個。

您可以使用命令ldd ./rtspclient.o檢查程序使用的libcurl。

爲了加載你建庫,你可以運行:

LD_LIBRARY_PATH=/path/to/curl/curlinst/lib/ ./rtspclient.o rtsp://192.168.1.5:554/streamingVideos_10/Movie8minMedium.mov 2000 0 10