1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
12 #include <curl/mprintf.h>
16 /* build request url */
17 static char *suburl(const char *base, int i)
19 return curl_maprintf("%s%.4d", base, i);
23 * Test Session ID capture
29 char *stream_uri = NULL;
30 char *rtsp_session_id;
35 idfile = fopen(libtest_arg2, "wb");
37 fprintf(stderr, "couldn't open the Session ID File\n");
38 return TEST_ERR_MAJOR_BAD;
41 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
42 fprintf(stderr, "curl_global_init() failed\n");
44 return TEST_ERR_MAJOR_BAD;
47 if ((curl = curl_easy_init()) == NULL) {
48 fprintf(stderr, "curl_easy_init() failed\n");
49 curl_global_cleanup();
51 return TEST_ERR_MAJOR_BAD;
54 test_setopt(curl, CURLOPT_HEADERDATA, stdout);
55 test_setopt(curl, CURLOPT_WRITEDATA, stdout);
56 test_setopt(curl, CURLOPT_VERBOSE, 1L);
58 test_setopt(curl, CURLOPT_URL, URL);
60 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
61 res = curl_easy_perform(curl);
62 if(res != (int)CURLE_BAD_FUNCTION_ARGUMENT) {
63 fprintf(stderr, "This should have failed. "
64 "Cannot setup without a Transport: header");
65 res = TEST_ERR_MAJOR_BAD;
69 /* Go through the various Session IDs */
70 for(i = 0; i < 3; i++) {
71 if((stream_uri = suburl(URL, request++)) == NULL) {
72 res = TEST_ERR_MAJOR_BAD;
75 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
79 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
80 test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Fake/NotReal/JustATest;foo=baz");
81 res = curl_easy_perform(curl);
85 curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id);
86 fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id);
87 rtsp_session_id = NULL;
89 if((stream_uri = suburl(URL, request++)) == NULL) {
90 res = TEST_ERR_MAJOR_BAD;
93 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
97 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN);
98 res = curl_easy_perform(curl);
100 /* Clear for the next go-round */
101 test_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL);
112 curl_easy_cleanup(curl);
113 curl_global_cleanup();