mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-01 07:22:23 +08:00
优化http分包器性能
This commit is contained in:
@@ -140,15 +140,11 @@ void RtspSession::onManager() {
|
||||
}
|
||||
|
||||
|
||||
void RtspSession::onRecvContent(const string &content){
|
||||
|
||||
}
|
||||
|
||||
int64_t RtspSession::onRecvHeader(const string &header) {
|
||||
int64_t RtspSession::onRecvHeader(const char *header,uint64_t len) {
|
||||
char tmp[2 * 1024];
|
||||
m_pcBuf = tmp;
|
||||
|
||||
m_parser.Parse(header.data()); //rtsp请求解析
|
||||
m_parser.Parse(header); //rtsp请求解析
|
||||
string strCmd = m_parser.Method(); //提取出请求命令字
|
||||
m_iCseq = atoi(m_parser["CSeq"].data());
|
||||
|
||||
@@ -188,18 +184,19 @@ void RtspSession::onRecv(const Buffer::Ptr &pBuf) {
|
||||
m_ui64TotalBytes += pBuf->size();
|
||||
if (m_bBase64need) {
|
||||
//quicktime 加密后的rtsp请求,需要解密
|
||||
inputRtspOrRtcp(decodeBase64(string(pBuf->data(),pBuf->size())));
|
||||
auto str = decodeBase64(string(pBuf->data(),pBuf->size()));
|
||||
inputRtspOrRtcp(str.data(),str.size());
|
||||
} else {
|
||||
inputRtspOrRtcp(string(pBuf->data(),pBuf->size()));
|
||||
inputRtspOrRtcp(pBuf->data(),pBuf->size());
|
||||
}
|
||||
}
|
||||
|
||||
void RtspSession::inputRtspOrRtcp(const string &str) {
|
||||
if(str[0] == '$' && m_rtpType == PlayerBase::RTP_TCP){
|
||||
void RtspSession::inputRtspOrRtcp(const char *data,uint64_t len) {
|
||||
if(data[0] == '$' && m_rtpType == PlayerBase::RTP_TCP){
|
||||
//这是rtcp
|
||||
return;
|
||||
}
|
||||
input(str);
|
||||
input(data,len);
|
||||
}
|
||||
|
||||
bool RtspSession::handleReq_Options() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
@@ -84,24 +84,9 @@ public:
|
||||
|
||||
protected:
|
||||
//HttpRequestSplitter override
|
||||
/**
|
||||
* 收到请求头
|
||||
* @param header 请求头
|
||||
* @return 请求头后的content长度,
|
||||
* <0 : 代表后面所有数据都是content
|
||||
* 0 : 代表为后面数据还是请求头,
|
||||
* >0 : 代表后面数据为固定长度content,
|
||||
*/
|
||||
int64_t onRecvHeader(const string &header) override ;
|
||||
|
||||
/**
|
||||
* 收到content分片或全部数据
|
||||
* onRecvHeader函数返回>0,则为全部数据
|
||||
* @param content
|
||||
*/
|
||||
void onRecvContent(const string &content) override;
|
||||
int64_t onRecvHeader(const char *data,uint64_t len) override ;
|
||||
private:
|
||||
void inputRtspOrRtcp(const string &str);
|
||||
void inputRtspOrRtcp(const char *data,uint64_t len);
|
||||
int send(const string &strBuf) override {
|
||||
m_ui64TotalBytes += strBuf.size();
|
||||
return m_pSender->send(strBuf);
|
||||
|
||||
Reference in New Issue
Block a user