优化rtmp相关性能

This commit is contained in:
xiongziliang 2019-02-28 18:20:17 +08:00
parent e7fc22ad53
commit e240044f2f
3 changed files with 20 additions and 2 deletions

View File

@ -139,6 +139,24 @@ public:
uint32_t streamId; uint32_t streamId;
uint32_t chunkId; uint32_t chunkId;
std::string strBuf; std::string strBuf;
public:
RtmpPacket() = default;
RtmpPacket(const RtmpPacket &that) = default;
RtmpPacket &operator=(const RtmpPacket &that) = default;
RtmpPacket &operator=(RtmpPacket &&that) = default;
RtmpPacket(RtmpPacket &&that){
typeId = that.typeId;
bodySize = that.bodySize;
timeStamp = that.timeStamp;
hasAbsStamp = that.hasAbsStamp;
hasExtStamp = that.hasExtStamp;
deltaStamp = that.deltaStamp;
streamId = that.streamId;
chunkId = that.chunkId;
strBuf = std::move(that.strBuf);
}
bool isVideoKeyFrame() const { bool isVideoKeyFrame() const {
return typeId == MSG_VIDEO && (uint8_t) strBuf[0] >> 4 == FLV_KEY_FRAME return typeId == MSG_VIDEO && (uint8_t) strBuf[0] >> 4 == FLV_KEY_FRAME
&& (uint8_t) strBuf[1] == 1; && (uint8_t) strBuf[1] == 1;

View File

@ -311,7 +311,7 @@ void RtmpPlayer::onRtmpChunk(RtmpPacket &chunkData) {
if (_aNowStampTicker[idx].elapsedTime() > 500) { if (_aNowStampTicker[idx].elapsedTime() > 500) {
_aiNowStamp[idx] = chunkData.timeStamp; _aiNowStamp[idx] = chunkData.timeStamp;
} }
_onMediaData(std::make_shared<RtmpPacket>(chunkData)); _onMediaData(std::make_shared<RtmpPacket>(std::move(chunkData)));
} }
break; break;
default: default:

View File

@ -522,7 +522,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) {
if(rtmp_modify_stamp){ if(rtmp_modify_stamp){
chunkData.timeStamp = _stampTicker[chunkData.typeId % 2].elapsedTime(); chunkData.timeStamp = _stampTicker[chunkData.typeId % 2].elapsedTime();
} }
_pPublisherSrc->onWrite(std::make_shared<RtmpPacket>(chunkData)); _pPublisherSrc->onWrite(std::make_shared<RtmpPacket>(std::move(chunkData)));
} }
break; break;
default: default: