Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

43 рядки
1.4KB

  1. #include "rtsp-server-internal.h"
  2. #include "http-header-content-type.h"
  3. #include "rfc822-datetime.h"
  4. int rtsp_server_announce(struct rtsp_server_t *rtsp, const char* uri)
  5. {
  6. const char* content;
  7. const char* pcontenttype;
  8. struct http_header_content_type_t content_type;
  9. memset(&content_type, 0, sizeof(content_type));
  10. pcontenttype = http_get_header_by_name(rtsp->parser, "Content-Type");
  11. if (!pcontenttype || 0 != http_header_content_type(pcontenttype, &content_type)
  12. || 0 != strcasecmp(content_type.media_type, "application")
  13. || 0 != strcasecmp(content_type.media_subtype, "sdp"))
  14. {
  15. // 406 Not Acceptable
  16. // 415 Unsupported Media Type ?
  17. return rtsp_server_reply(rtsp, 406);
  18. }
  19. content = (const char*)http_get_content(rtsp->parser);
  20. return rtsp->handler.onannounce(rtsp->param, rtsp, uri, content, (int)http_get_content_length(rtsp->parser));
  21. }
  22. int rtsp_server_reply_announce(struct rtsp_server_t *rtsp, int code)
  23. {
  24. int len;
  25. rfc822_datetime_t datetime;
  26. if (200 != code)
  27. return rtsp_server_reply(rtsp, code);
  28. len = snprintf(rtsp->reply, sizeof(rtsp->reply),
  29. "RTSP/1.0 200 OK\r\n"
  30. "CSeq: %u\r\n"
  31. "Date: %s\r\n"
  32. "\r\n",
  33. rtsp->cseq,
  34. rfc822_datetime_format(time(NULL), datetime));
  35. return rtsp->handler.send(rtsp->sendparam, rtsp->reply, len);
  36. }