You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.4KB

  1. /*
  2. C->S:
  3. OPTIONS * RTSP/1.0
  4. CSeq: 1
  5. Require: implicit-play
  6. Proxy-Require: gzipped-messages
  7. S->C:
  8. RTSP/1.0 200 OK
  9. CSeq: 1
  10. Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE
  11. */
  12. #include "rtsp-client-internal.h"
  13. static const char* sc_format =
  14. "OPTIONS * RTSP/1.0\r\n"
  15. "CSeq: %u\r\n"
  16. "%s" // "Require: implicit-play\r\n"
  17. "%s" // "Session: xxx\r\n"
  18. "User-Agent: %s\r\n"
  19. "\r\n";
  20. int rtsp_client_options(struct rtsp_client_t *rtsp, const char* commands)
  21. {
  22. int r = 0;
  23. char require[128];
  24. char session[128];
  25. rtsp->state = RTSP_OPTIONS;
  26. require[0] = session[0] = '\0';
  27. if ((commands && commands[0] && sizeof(require) <= snprintf(require, sizeof(require), "Require: %s\r\n", commands))
  28. || (rtsp->media_count > 0 && *rtsp->session[0].session && sizeof(session) <= snprintf(session, sizeof(session) - 1, "Session: %s\r\n", rtsp->session[0].session)))
  29. return -1;
  30. r = snprintf(rtsp->req, sizeof(rtsp->req), sc_format, rtsp->cseq++, require, session, USER_AGENT);
  31. return (r > 0 && r < sizeof(rtsp->req) && r == rtsp->handler.send(rtsp->param, rtsp->uri, rtsp->req, r)) ? 0 : -1;
  32. }
  33. int rtsp_client_options_onreply(struct rtsp_client_t* rtsp, void* parser)
  34. {
  35. int code;
  36. const char *methods;
  37. assert(RTSP_OPTIONS == rtsp->state);
  38. code = http_get_status_code(parser);
  39. if (200 == code)
  40. {
  41. methods = http_get_header_by_name(parser, "Public");
  42. (void)methods; // TODO: check support methods
  43. return 0; // next step
  44. }
  45. else
  46. {
  47. return -1;
  48. }
  49. }