lib570.c (3330B)
1 /*************************************************************************** 2 * _ _ ____ _ 3 * Project ___| | | | _ \| | 4 * / __| | | | |_) | | 5 * | (__| |_| | _ <| |___ 6 * \___|\___/|_| \_\_____| 7 * 8 * Copyright (C) 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 https://curl.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 * SPDX-License-Identifier: curl 22 * 23 ***************************************************************************/ 24 #include "first.h" 25 26 #include "testutil.h" 27 #include "memdebug.h" 28 29 static CURLcode test_lib570(char *URL) 30 { 31 CURLcode res; 32 CURL *curl; 33 int request = 1; 34 char *stream_uri = NULL; 35 36 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { 37 curl_mfprintf(stderr, "curl_global_init() failed\n"); 38 return TEST_ERR_MAJOR_BAD; 39 } 40 41 curl = curl_easy_init(); 42 if(!curl) { 43 curl_mfprintf(stderr, "curl_easy_init() failed\n"); 44 curl_global_cleanup(); 45 return TEST_ERR_MAJOR_BAD; 46 } 47 48 test_setopt(curl, CURLOPT_HEADERDATA, stdout); 49 test_setopt(curl, CURLOPT_WRITEDATA, stdout); 50 test_setopt(curl, CURLOPT_VERBOSE, 1L); 51 52 test_setopt(curl, CURLOPT_URL, URL); 53 54 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); 55 56 stream_uri = tutil_suburl(URL, request++); 57 if(!stream_uri) { 58 res = TEST_ERR_MAJOR_BAD; 59 goto test_cleanup; 60 } 61 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); 62 curl_free(stream_uri); 63 stream_uri = NULL; 64 65 res = curl_easy_perform(curl); 66 if(res != (int)CURLE_RTSP_CSEQ_ERROR) { 67 curl_mfprintf(stderr, "Failed to detect CSeq mismatch"); 68 res = TEST_ERR_MAJOR_BAD; 69 goto test_cleanup; 70 } 71 72 test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999L); 73 test_setopt(curl, CURLOPT_RTSP_TRANSPORT, 74 "RAW/RAW/UDP;unicast;client_port=3056-3057"); 75 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); 76 77 stream_uri = tutil_suburl(URL, request++); 78 if(!stream_uri) { 79 res = TEST_ERR_MAJOR_BAD; 80 goto test_cleanup; 81 } 82 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); 83 curl_free(stream_uri); 84 stream_uri = NULL; 85 86 res = curl_easy_perform(curl); 87 if(res) 88 goto test_cleanup; 89 90 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); 91 92 stream_uri = tutil_suburl(URL, request++); 93 if(!stream_uri) { 94 res = TEST_ERR_MAJOR_BAD; 95 goto test_cleanup; 96 } 97 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); 98 curl_free(stream_uri); 99 stream_uri = NULL; 100 101 res = curl_easy_perform(curl); 102 if(res == CURLE_RTSP_SESSION_ERROR) { 103 res = CURLE_OK; 104 } 105 else { 106 curl_mfprintf(stderr, "Failed to detect a Session ID mismatch"); 107 res = TEST_ERR_FAILURE; 108 } 109 110 test_cleanup: 111 curl_free(stream_uri); 112 113 curl_easy_cleanup(curl); 114 curl_global_cleanup(); 115 116 return res; 117 }