mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
添加性能测试模式
This commit is contained in:
parent
5025d7d4cc
commit
0fc1499643
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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());
|
||||
|
@ -102,6 +102,8 @@ private:
|
||||
uint32_t _aiNowStamp[2] = { 0, 0 };
|
||||
Ticker _aNowStampTicker[2];
|
||||
bool _metadata_got = false;
|
||||
//是否为性能测试模式
|
||||
bool _benchmark_mode = false;
|
||||
};
|
||||
|
||||
} /* namespace mediakit */
|
||||
|
@ -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);
|
||||
|
@ -139,6 +139,8 @@ private:
|
||||
|
||||
//是否为rtsp点播
|
||||
bool _is_play_back;
|
||||
//是否为性能测试模式
|
||||
bool _benchmark_mode = false;
|
||||
};
|
||||
|
||||
} /* namespace mediakit */
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user