diff --git a/src/Rtmp/FlvPlayer.cpp b/src/Rtmp/FlvPlayer.cpp index fbefd23e..0095eb04 100644 --- a/src/Rtmp/FlvPlayer.cpp +++ b/src/Rtmp/FlvPlayer.cpp @@ -54,7 +54,10 @@ void FlvPlayer::onResponseCompleted(const SockException &ex) { } void FlvPlayer::onResponseBody(const char *buf, size_t size) { - FlvSplitter::input(buf, size); + if (!_benchmark_mode) { + // 性能测试模式不做数据解析,节省cpu + FlvSplitter::input(buf, size); + } } bool FlvPlayer::onRecvMetadata(const AMFValue &metadata) { @@ -64,6 +67,7 @@ bool FlvPlayer::onRecvMetadata(const AMFValue &metadata) { void FlvPlayer::onRecvRtmpPacket(RtmpPacket::Ptr packet) { if (!_play_result && !packet->isConfigFrame()) { _play_result = true; + _benchmark_mode = (*this)[Client::kBenchmarkMode].as(); onPlayResult(SockException(Err_success, "play http-flv success")); } onRtmpPacket(std::move(packet)); diff --git a/src/Rtmp/FlvPlayer.h b/src/Rtmp/FlvPlayer.h index c49b2b3f..2e79dac2 100644 --- a/src/Rtmp/FlvPlayer.h +++ b/src/Rtmp/FlvPlayer.h @@ -40,6 +40,7 @@ private: private: bool _play_result = false; + bool _benchmark_mode = false; }; using FlvPlayerImp = FlvPlayerBase;