添加性能测试模式

This commit is contained in:
xiongziliang 2020-04-08 11:16:09 +08:00
parent 5025d7d4cc
commit 0fc1499643
7 changed files with 23 additions and 0 deletions

View File

@ -286,6 +286,8 @@ const string kTimeoutMS = "protocol_timeout_ms";
const string kMediaTimeoutMS = "media_timeout_ms";
const string kBeatIntervalMS = "beat_interval_ms";
const string kMaxAnalysisMS = "max_analysis_ms";
const string kBenchmarkMode = "benchmark_mode";
}
} // namespace mediakit

View File

@ -315,6 +315,8 @@ extern const string kMediaTimeoutMS;
extern const string kBeatIntervalMS;
//Track编码格式探测最大时间单位毫秒默认2000
extern const string kMaxAnalysisMS;
//是否为性能测试模式性能测试模式开启后不会解析rtp或rtmp包
extern const string kBenchmarkMode;
}
} // namespace mediakit

View File

@ -118,6 +118,8 @@ void RtmpPlayer::onPlayResult_l(const SockException &ex , bool handshakeComplete
//开始播放阶段
_pPlayTimer.reset();
onPlayResult(ex);
//是否为性能测试模式
_benchmark_mode = (*this)[Client::kBenchmarkMode].as<int>();
} else if (ex) {
//播放成功后异常断开回调
onShutdown(ex);
@ -146,6 +148,11 @@ void RtmpPlayer::onConnect(const SockException &err){
}
void RtmpPlayer::onRecv(const Buffer::Ptr &pBuf){
try {
if(_benchmark_mode && !_pPlayTimer){
//在性能测试模式下如果rtmp握手完毕后不再解析rtmp包
_mediaTicker.resetTime();
return;
}
onParseRtmp(pBuf->data(), pBuf->size());
} catch (exception &e) {
SockException ex(Err_other, e.what());

View File

@ -102,6 +102,8 @@ private:
uint32_t _aiNowStamp[2] = { 0, 0 };
Ticker _aNowStampTicker[2];
bool _metadata_got = false;
//是否为性能测试模式
bool _benchmark_mode = false;
};
} /* namespace mediakit */

View File

@ -112,6 +112,11 @@ void RtspPlayer::onConnect(const SockException &err){
}
void RtspPlayer::onRecv(const Buffer::Ptr& pBuf) {
if(_benchmark_mode && !_pPlayTimer){
//在性能测试模式下如果rtsp握手完毕后不再解析rtp包
_rtpTicker.resetTime();
return;
}
input(pBuf->data(),pBuf->size());
}
void RtspPlayer::onErr(const SockException &ex) {
@ -750,6 +755,8 @@ void RtspPlayer::onPlayResult_l(const SockException &ex , bool handshakeComplete
//开始播放阶段
_pPlayTimer.reset();
onPlayResult(ex);
//是否为性能测试模式
_benchmark_mode = (*this)[Client::kBenchmarkMode].as<int>();
} else if (ex) {
//播放成功后异常断开回调
onShutdown(ex);

View File

@ -139,6 +139,8 @@ private:
//是否为rtsp点播
bool _is_play_back;
//是否为性能测试模式
bool _benchmark_mode = false;
};
} /* namespace mediakit */

View File

@ -55,6 +55,7 @@ int main(int argc, char *argv[]) {
player->setOnShutdown([&](const SockException &ex) {
--alivePlayerCnt;
});
(*player)[kBenchmarkMode] = true;
(*player)[kRtpType] = atoi(argv[4]);
player->play(argv[3]);
playerList.push_back(player);