优化rtsp服务器性能

This commit is contained in:
xiongziliang 2019-06-11 18:31:34 +08:00
parent 74429db335
commit ce9a9188b2
3 changed files with 14 additions and 4 deletions

View File

@ -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) {

View File

@ -186,7 +186,7 @@ private:
//一次发送 get 一次发送post需要通过x-sessioncookie关联起来
string _http_x_sessioncookie;
function<void(const Buffer::Ptr &pBuf)> _onRecv;
atomic<bool> _enableSendRtp;
bool _enableSendRtp;
//rtsp推流相关
RtspToRtmpMediaSource::Ptr _pushSrc;

View File

@ -35,7 +35,7 @@ using namespace toolkit;
namespace mediakit{
class RtpPacket {
class RtpPacket : public Buffer{
public:
typedef std::shared_ptr<RtpPacket> 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 {