http-flv拉流客户端支持压测模式

This commit is contained in:
xia-chu 2023-09-23 20:34:43 +08:00
parent 585f7c3a3a
commit d542eca4d7
2 changed files with 6 additions and 1 deletions

View File

@ -54,8 +54,11 @@ void FlvPlayer::onResponseCompleted(const SockException &ex) {
} }
void FlvPlayer::onResponseBody(const char *buf, size_t size) { void FlvPlayer::onResponseBody(const char *buf, size_t size) {
if (!_benchmark_mode) {
// 性能测试模式不做数据解析节省cpu
FlvSplitter::input(buf, size); FlvSplitter::input(buf, size);
} }
}
bool FlvPlayer::onRecvMetadata(const AMFValue &metadata) { bool FlvPlayer::onRecvMetadata(const AMFValue &metadata) {
return onMetadata(metadata); return onMetadata(metadata);
@ -64,6 +67,7 @@ bool FlvPlayer::onRecvMetadata(const AMFValue &metadata) {
void FlvPlayer::onRecvRtmpPacket(RtmpPacket::Ptr packet) { void FlvPlayer::onRecvRtmpPacket(RtmpPacket::Ptr packet) {
if (!_play_result && !packet->isConfigFrame()) { if (!_play_result && !packet->isConfigFrame()) {
_play_result = true; _play_result = true;
_benchmark_mode = (*this)[Client::kBenchmarkMode].as<int>();
onPlayResult(SockException(Err_success, "play http-flv success")); onPlayResult(SockException(Err_success, "play http-flv success"));
} }
onRtmpPacket(std::move(packet)); onRtmpPacket(std::move(packet));

View File

@ -40,6 +40,7 @@ private:
private: private:
bool _play_result = false; bool _play_result = false;
bool _benchmark_mode = false;
}; };
using FlvPlayerImp = FlvPlayerBase<FlvPlayer>; using FlvPlayerImp = FlvPlayerBase<FlvPlayer>;