lib570.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #include "test.h"
  23. #include <curl/mprintf.h>
  24. #include "memdebug.h"
  25. /* build request url */
  26. static char *suburl(const char *base, int i)
  27. {
  28. return curl_maprintf("%s%.4d", base, i);
  29. }
  30. int test(char *URL)
  31. {
  32. int res;
  33. CURL *curl;
  34. int request=1;
  35. char *stream_uri = NULL;
  36. if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
  37. fprintf(stderr, "curl_global_init() failed\n");
  38. return TEST_ERR_MAJOR_BAD;
  39. }
  40. if ((curl = curl_easy_init()) == NULL) {
  41. fprintf(stderr, "curl_easy_init() failed\n");
  42. curl_global_cleanup();
  43. return TEST_ERR_MAJOR_BAD;
  44. }
  45. test_setopt(curl, CURLOPT_HEADERDATA, stdout);
  46. test_setopt(curl, CURLOPT_WRITEDATA, stdout);
  47. test_setopt(curl, CURLOPT_VERBOSE, 1L);
  48. test_setopt(curl, CURLOPT_URL, URL);
  49. test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
  50. if((stream_uri = suburl(URL, request++)) == NULL) {
  51. res = TEST_ERR_MAJOR_BAD;
  52. goto test_cleanup;
  53. }
  54. test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
  55. free(stream_uri);
  56. stream_uri = NULL;
  57. res = curl_easy_perform(curl);
  58. if(res != (int)CURLE_RTSP_CSEQ_ERROR) {
  59. fprintf(stderr, "Failed to detect CSeq mismatch");
  60. res = TEST_ERR_MAJOR_BAD;
  61. goto test_cleanup;
  62. }
  63. test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999);
  64. test_setopt(curl, CURLOPT_RTSP_TRANSPORT,
  65. "RAW/RAW/UDP;unicast;client_port=3056-3057");
  66. test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
  67. if((stream_uri = suburl(URL, request++)) == NULL) {
  68. res = TEST_ERR_MAJOR_BAD;
  69. goto test_cleanup;
  70. }
  71. test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
  72. free(stream_uri);
  73. stream_uri = NULL;
  74. res = curl_easy_perform(curl);
  75. if(res)
  76. goto test_cleanup;
  77. test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
  78. if((stream_uri = suburl(URL, request++)) == NULL) {
  79. res = TEST_ERR_MAJOR_BAD;
  80. goto test_cleanup;
  81. }
  82. test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
  83. free(stream_uri);
  84. stream_uri = NULL;
  85. res = curl_easy_perform(curl);
  86. if(res != CURLE_RTSP_SESSION_ERROR) {
  87. fprintf(stderr, "Failed to detect a Session ID mismatch");
  88. }
  89. test_cleanup:
  90. if(stream_uri)
  91. free(stream_uri);
  92. curl_easy_cleanup(curl);
  93. curl_global_cleanup();
  94. return res;
  95. }