Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

74 Zeilen
2.0KB

  1. /*
  2. ANNOUNCE rtsp://server.example.com/fizzle/foo RTSP/1.0
  3. CSeq: 312
  4. Date: 23 Jan 1997 15:35:06 GMT
  5. Session: 47112344
  6. Content-Type: application/sdp
  7. Content-Length: 332
  8. v=0
  9. o=mhandley 2890844526 2890845468 IN IP4 126.16.64.4
  10. s=SDP Seminar
  11. i=A Seminar on the session description protocol
  12. u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps
  13. e=mjh@isi.edu (Mark Handley)
  14. c=IN IP4 224.2.17.12/127
  15. t=2873397496 2873404696
  16. a=recvonly
  17. m=audio 3456 RTP/AVP 0
  18. m=video 2232 RTP/AVP 31
  19. */
  20. #include "rtsp-client.h"
  21. #include "rtsp-client-internal.h"
  22. static const char* sc_format =
  23. "ANNOUNCE %s RTSP/1.0\r\n"
  24. "CSeq: %u\r\n"
  25. "Session: %s\r\n"
  26. "%s" // Authorization: Digest xxx
  27. "Content-Type: application/sdp\r\n"
  28. "Content-Length: %u\r\n"
  29. "\r\n"
  30. "%s";
  31. int rtsp_client_announce(struct rtsp_client_t* rtsp, const char* sdp)
  32. {
  33. int r;
  34. rtsp->progress = 0;
  35. rtsp->state = RTSP_ANNOUNCE;
  36. rtsp->announce = sdp; // hijack
  37. r = rtsp_client_authenrization(rtsp, "ANNOUNCE", rtsp->uri, sdp, (int)strlen(sdp), rtsp->authenrization, sizeof(rtsp->authenrization));
  38. r = snprintf(rtsp->req, sizeof(rtsp->req), sc_format, rtsp->uri, rtsp->cseq++, rtsp->session[0].session, rtsp->authenrization, (unsigned int)strlen(sdp), sdp);
  39. assert(r > 0 && r < sizeof(rtsp->req));
  40. return r == rtsp->handler.send(rtsp->param, rtsp->uri, rtsp->req, r) ? 0 : -1;
  41. }
  42. int rtsp_client_announce_onreply(struct rtsp_client_t* rtsp, void* parser)
  43. {
  44. int code, r;
  45. assert(0 == rtsp->progress);
  46. assert(RTSP_ANNOUNCE == rtsp->state);
  47. r = -1;
  48. code = http_get_status_code(parser);
  49. if (200 == code)
  50. {
  51. rtsp->auth_failed = 0;
  52. r = rtsp->handler.onannounce(rtsp->param);
  53. }
  54. else if(401 == code)
  55. {
  56. // Unauthorized
  57. const char* authenticate;
  58. authenticate = http_get_header_by_name(parser, "WWW-Authenticate");
  59. if (authenticate && 0 == rtsp->auth_failed++)
  60. {
  61. rtsp_client_www_authenticate(rtsp, authenticate);
  62. r = rtsp_client_announce(rtsp, rtsp->announce);
  63. }
  64. }
  65. return r;
  66. }