From d542eca4d733d641b95f927b148aeae8a78e3bcf Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 23 Sep 2023 20:34:43 +0800 Subject: [PATCH] =?UTF-8?q?http-flv=E6=8B=89=E6=B5=81=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E6=94=AF=E6=8C=81=E5=8E=8B=E6=B5=8B=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtmp/FlvPlayer.cpp | 6 +++++- src/Rtmp/FlvPlayer.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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;