1/*************************************************************************** 2 * _ _ ____ _ 3 * Project ___| | | | _ \| | 4 * / __| | | | |_) | | 5 * | (__| |_| | _ <| |___ 6 * \___|\___/|_| \_\_____| 7 * 8 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. 9 * 10 * This software is licensed as described in the file COPYING, which 11 * you should have received as part of this distribution. The terms 12 * are also available at http://curl.haxx.se/docs/copyright.html. 13 * 14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 15 * copies of the Software, and permit persons to whom the Software is 16 * furnished to do so, under the terms of the COPYING file. 17 * 18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19 * KIND, either express or implied. 20 * 21 ***************************************************************************/ 22 23#include "test.h" 24 25#include <curl/mprintf.h> 26 27#include "memdebug.h" 28 29/* build request url */ 30static char *suburl(const char *base, int i) 31{ 32 return curl_maprintf("%s%.4d", base, i); 33} 34 35int test(char *URL) 36{ 37 int res; 38 CURL *curl; 39 int request=1; 40 char *stream_uri = NULL; 41 42 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { 43 fprintf(stderr, "curl_global_init() failed\n"); 44 return TEST_ERR_MAJOR_BAD; 45 } 46 47 if ((curl = curl_easy_init()) == NULL) { 48 fprintf(stderr, "curl_easy_init() failed\n"); 49 curl_global_cleanup(); 50 return TEST_ERR_MAJOR_BAD; 51 } 52 53 test_setopt(curl, CURLOPT_HEADERDATA, stdout); 54 test_setopt(curl, CURLOPT_WRITEDATA, stdout); 55 test_setopt(curl, CURLOPT_VERBOSE, 1L); 56 57 test_setopt(curl, CURLOPT_URL, URL); 58 59 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); 60 61 if((stream_uri = suburl(URL, request++)) == NULL) { 62 res = TEST_ERR_MAJOR_BAD; 63 goto test_cleanup; 64 } 65 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); 66 free(stream_uri); 67 stream_uri = NULL; 68 69 res = curl_easy_perform(curl); 70 if(res != (int)CURLE_RTSP_CSEQ_ERROR) { 71 fprintf(stderr, "Failed to detect CSeq mismatch"); 72 res = TEST_ERR_MAJOR_BAD; 73 goto test_cleanup; 74 } 75 76 test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999); 77 test_setopt(curl, CURLOPT_RTSP_TRANSPORT, 78 "RAW/RAW/UDP;unicast;client_port=3056-3057"); 79 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); 80 81 if((stream_uri = suburl(URL, request++)) == NULL) { 82 res = TEST_ERR_MAJOR_BAD; 83 goto test_cleanup; 84 } 85 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); 86 free(stream_uri); 87 stream_uri = NULL; 88 89 res = curl_easy_perform(curl); 90 if(res) 91 goto test_cleanup; 92 93 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); 94 95 if((stream_uri = suburl(URL, request++)) == NULL) { 96 res = TEST_ERR_MAJOR_BAD; 97 goto test_cleanup; 98 } 99 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); 100 free(stream_uri); 101 stream_uri = NULL; 102 103 res = curl_easy_perform(curl); 104 if(res != CURLE_RTSP_SESSION_ERROR) { 105 fprintf(stderr, "Failed to detect a Session ID mismatch"); 106 } 107 108test_cleanup: 109 110 if(stream_uri) 111 free(stream_uri); 112 113 curl_easy_cleanup(curl); 114 curl_global_cleanup(); 115 116 return res; 117} 118 119