From ce9a9188b254b47ee2139c5c61e45001d58fe579 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 11 Jun 2019 18:31:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96rtsp=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtspSession.cpp | 7 +++++-- src/Rtsp/RtspSession.h | 2 +- src/RtspMuxer/RtpCodec.h | 9 ++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index ec911339..0abae3f2 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -37,6 +37,8 @@ #include "Util/NoticeCenter.h" #include "Network/sockutil.h" +#define RTSP_SERVER_SEND_RTCP 0 + using namespace std; using namespace toolkit; @@ -1112,8 +1114,7 @@ inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) { //InfoP(this) <<(int)pkt.Interleaved; switch (_rtpType) { case Rtsp::RTP_TCP: { - BufferRtp::Ptr buffer(new BufferRtp(pkt)); - send(buffer); + send(pkt); } break; case Rtsp::RTP_UDP: { @@ -1132,6 +1133,7 @@ inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) { break; } +#if RTSP_SERVER_SEND_RTCP int iTrackIndex = getTrackIndexByInterleaved(pkt->interleaved); if(iTrackIndex == -1){ return; @@ -1147,6 +1149,7 @@ inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) { memcpy(&counter.timeStamp, pkt->payload + 8 , 4); sendSenderReport(_rtpType == Rtsp::RTP_TCP,iTrackIndex); } +#endif } inline void RtspSession::sendSenderReport(bool overTcp,int iTrackIndex) { diff --git a/src/Rtsp/RtspSession.h b/src/Rtsp/RtspSession.h index 30f42cfd..6d5b064f 100644 --- a/src/Rtsp/RtspSession.h +++ b/src/Rtsp/RtspSession.h @@ -186,7 +186,7 @@ private: //一次发送 get 一次发送post,需要通过x-sessioncookie关联起来 string _http_x_sessioncookie; function _onRecv; - atomic _enableSendRtp; + bool _enableSendRtp; //rtsp推流相关 RtspToRtmpMediaSource::Ptr _pushSrc; diff --git a/src/RtspMuxer/RtpCodec.h b/src/RtspMuxer/RtpCodec.h index 21bc9279..3e172477 100644 --- a/src/RtspMuxer/RtpCodec.h +++ b/src/RtspMuxer/RtpCodec.h @@ -35,7 +35,7 @@ using namespace toolkit; namespace mediakit{ -class RtpPacket { +class RtpPacket : public Buffer{ public: typedef std::shared_ptr Ptr; uint8_t interleaved; @@ -49,6 +49,13 @@ public: uint8_t payload[1604]; uint8_t offset; TrackType type; + + char *data() const override { + return (char *)payload; + } + uint32_t size() const override { + return length; + } }; class RtpRingInterface {