25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
847B

  1. #ifndef _rtp_tcp_transport_h_
  2. #define _rtp_tcp_transport_h_
  3. #include "media/media-source.h"
  4. class RTPTcpTransport : public IRTPTransport
  5. {
  6. public:
  7. RTPTcpTransport(rtsp_server_t* rtsp, uint8_t rtp, uint8_t rtcp): m_rtp(rtp), m_rtcp(rtcp), m_rtsp(rtsp) {}
  8. virtual ~RTPTcpTransport() {}
  9. public:
  10. virtual int Send(bool rtcp, const void* data, size_t bytes)
  11. {
  12. assert(bytes < (1 << 16));
  13. if (bytes >= (1 << 16))
  14. return -E2BIG;
  15. m_packet[0] = '$';
  16. m_packet[1] = rtcp ? m_rtcp : m_rtp;
  17. m_packet[2] = (bytes >> 8) & 0xFF;
  18. m_packet[3] = bytes & 0xff;
  19. memcpy(m_packet + 4, data, bytes);
  20. int r = rtsp_server_send_interleaved_data(m_rtsp, m_packet, bytes + 4);
  21. return 0 == r ? bytes : r;
  22. }
  23. private:
  24. uint8_t m_rtp;
  25. uint8_t m_rtcp;
  26. rtsp_server_t* m_rtsp;
  27. uint8_t m_packet[4 + (1 << 16)];
  28. };
  29. #endif /* !_rtp_tcp_transport_h_ */