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.

40 line
1.2KB

  1. #include "rtsp-server-internal.h"
  2. #include "rtsp-header-range.h"
  3. // RFC2326 10.6 PAUSE (p36)
  4. // 1. A PAUSE request discards all queued PLAY requests. However, the pause
  5. // point in the media stream MUST be maintained. A subsequent PLAY
  6. // request without Range header resumes from the pause point.
  7. int rtsp_server_pause(struct rtsp_server_t* rtsp, const char* uri)
  8. {
  9. int64_t npt = -1L;
  10. const char *prange;
  11. struct rtsp_header_range_t range;
  12. if (0 == rtsp->session.session[0])
  13. {
  14. // 454 Session Not Found
  15. return rtsp_server_reply(rtsp, 454);
  16. }
  17. prange = http_get_header_by_name(rtsp->parser, "range");
  18. if (prange && 0 == rtsp_header_range(prange, &range))
  19. {
  20. npt = range.from;
  21. // 10.6 The normal play time for the stream is set to the pause point. (p36)
  22. assert(range.type == RTSP_RANGE_NPT); // 3.6 Normal Play Time (p17)
  23. assert(range.to_value == RTSP_RANGE_TIME_NOVALUE);
  24. // 457 Invalid Range
  25. //rtsp_server_reply(req, 457, NULL);
  26. //return;
  27. }
  28. return rtsp->handler.onpause(rtsp->param, rtsp, uri, rtsp->session.session, -1L == npt ? NULL : &npt);
  29. }
  30. int rtsp_server_reply_pause(struct rtsp_server_t *rtsp, int code)
  31. {
  32. return rtsp_server_reply(rtsp, code);
  33. }