Commit ce9a9188 by xiongziliang

优化rtsp服务器性能

parent 74429db3
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include "Util/NoticeCenter.h" #include "Util/NoticeCenter.h"
#include "Network/sockutil.h" #include "Network/sockutil.h"
#define RTSP_SERVER_SEND_RTCP 0
using namespace std; using namespace std;
using namespace toolkit; using namespace toolkit;
...@@ -1112,8 +1114,7 @@ inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) { ...@@ -1112,8 +1114,7 @@ inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) {
//InfoP(this) <<(int)pkt.Interleaved; //InfoP(this) <<(int)pkt.Interleaved;
switch (_rtpType) { switch (_rtpType) {
case Rtsp::RTP_TCP: { case Rtsp::RTP_TCP: {
BufferRtp::Ptr buffer(new BufferRtp(pkt)); send(pkt);
send(buffer);
} }
break; break;
case Rtsp::RTP_UDP: { case Rtsp::RTP_UDP: {
...@@ -1132,6 +1133,7 @@ inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) { ...@@ -1132,6 +1133,7 @@ inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) {
break; break;
} }
#if RTSP_SERVER_SEND_RTCP
int iTrackIndex = getTrackIndexByInterleaved(pkt->interleaved); int iTrackIndex = getTrackIndexByInterleaved(pkt->interleaved);
if(iTrackIndex == -1){ if(iTrackIndex == -1){
return; return;
...@@ -1147,6 +1149,7 @@ inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) { ...@@ -1147,6 +1149,7 @@ inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) {
memcpy(&counter.timeStamp, pkt->payload + 8 , 4); memcpy(&counter.timeStamp, pkt->payload + 8 , 4);
sendSenderReport(_rtpType == Rtsp::RTP_TCP,iTrackIndex); sendSenderReport(_rtpType == Rtsp::RTP_TCP,iTrackIndex);
} }
#endif
} }
inline void RtspSession::sendSenderReport(bool overTcp,int iTrackIndex) { inline void RtspSession::sendSenderReport(bool overTcp,int iTrackIndex) {
......
...@@ -186,7 +186,7 @@ private: ...@@ -186,7 +186,7 @@ private:
//一次发送 get 一次发送post,需要通过x-sessioncookie关联起来 //一次发送 get 一次发送post,需要通过x-sessioncookie关联起来
string _http_x_sessioncookie; string _http_x_sessioncookie;
function<void(const Buffer::Ptr &pBuf)> _onRecv; function<void(const Buffer::Ptr &pBuf)> _onRecv;
atomic<bool> _enableSendRtp; bool _enableSendRtp;
//rtsp推流相关 //rtsp推流相关
RtspToRtmpMediaSource::Ptr _pushSrc; RtspToRtmpMediaSource::Ptr _pushSrc;
......
...@@ -35,7 +35,7 @@ using namespace toolkit; ...@@ -35,7 +35,7 @@ using namespace toolkit;
namespace mediakit{ namespace mediakit{
class RtpPacket { class RtpPacket : public Buffer{
public: public:
typedef std::shared_ptr<RtpPacket> Ptr; typedef std::shared_ptr<RtpPacket> Ptr;
uint8_t interleaved; uint8_t interleaved;
...@@ -49,6 +49,13 @@ public: ...@@ -49,6 +49,13 @@ public:
uint8_t payload[1604]; uint8_t payload[1604];
uint8_t offset; uint8_t offset;
TrackType type; TrackType type;
char *data() const override {
return (char *)payload;
}
uint32_t size() const override {
return length;
}
}; };
class RtpRingInterface { class RtpRingInterface {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论