Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "test.h"
00023 #include "memdebug.h"
00024
00025
00026 static char *suburl(const char *base, int i)
00027 {
00028 return curl_maprintf("%s%.4d", base, i);
00029 }
00030
00031
00032
00033
00034 int test(char *URL)
00035 {
00036 int res;
00037 CURL *curl;
00038 char *stream_uri = NULL;
00039 char *rtsp_session_id;
00040 int request=1;
00041 int i;
00042 FILE *idfile = NULL;
00043
00044 idfile = fopen(libtest_arg2, "wb");
00045 if(idfile == NULL) {
00046 fprintf(stderr, "couldn't open the Session ID File\n");
00047 return TEST_ERR_MAJOR_BAD;
00048 }
00049
00050 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
00051 fprintf(stderr, "curl_global_init() failed\n");
00052 fclose(idfile);
00053 return TEST_ERR_MAJOR_BAD;
00054 }
00055
00056 curl = curl_easy_init();
00057 if(!curl) {
00058 fprintf(stderr, "curl_easy_init() failed\n");
00059 curl_global_cleanup();
00060 fclose(idfile);
00061 return TEST_ERR_MAJOR_BAD;
00062 }
00063
00064 test_setopt(curl, CURLOPT_HEADERDATA, stdout);
00065 test_setopt(curl, CURLOPT_WRITEDATA, stdout);
00066 test_setopt(curl, CURLOPT_VERBOSE, 1L);
00067
00068 test_setopt(curl, CURLOPT_URL, URL);
00069
00070 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
00071 res = curl_easy_perform(curl);
00072 if(res != (int)CURLE_BAD_FUNCTION_ARGUMENT) {
00073 fprintf(stderr, "This should have failed. "
00074 "Cannot setup without a Transport: header");
00075 res = TEST_ERR_MAJOR_BAD;
00076 goto test_cleanup;
00077 }
00078
00079
00080 for(i = 0; i < 3; i++) {
00081 stream_uri = suburl(URL, request++);
00082 if(!stream_uri) {
00083 res = TEST_ERR_MAJOR_BAD;
00084 goto test_cleanup;
00085 }
00086 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
00087 free(stream_uri);
00088 stream_uri = NULL;
00089
00090 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
00091 test_setopt(curl, CURLOPT_RTSP_TRANSPORT,
00092 "Fake/NotReal/JustATest;foo=baz");
00093 res = curl_easy_perform(curl);
00094 if(res)
00095 goto test_cleanup;
00096
00097 curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id);
00098 fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id);
00099 rtsp_session_id = NULL;
00100
00101 stream_uri = suburl(URL, request++);
00102 if(!stream_uri) {
00103 res = TEST_ERR_MAJOR_BAD;
00104 goto test_cleanup;
00105 }
00106 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
00107 free(stream_uri);
00108 stream_uri = NULL;
00109
00110 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN);
00111 res = curl_easy_perform(curl);
00112
00113
00114 test_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL);
00115 }
00116
00117 test_cleanup:
00118
00119 if(idfile)
00120 fclose(idfile);
00121
00122 free(stream_uri);
00123 curl_easy_cleanup(curl);
00124 curl_global_cleanup();
00125
00126 return res;
00127 }
00128