From e240044f2fb1408bf4ca80c1565d4331f03d7372 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 28 Feb 2019 18:20:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96rtmp=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtmp/Rtmp.h | 18 ++++++++++++++++++ src/Rtmp/RtmpPlayer.cpp | 2 +- src/Rtmp/RtmpSession.cpp | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Rtmp/Rtmp.h b/src/Rtmp/Rtmp.h index 604beff9..879987be 100644 --- a/src/Rtmp/Rtmp.h +++ b/src/Rtmp/Rtmp.h @@ -139,6 +139,24 @@ public: uint32_t streamId; uint32_t chunkId; 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 { return typeId == MSG_VIDEO && (uint8_t) strBuf[0] >> 4 == FLV_KEY_FRAME && (uint8_t) strBuf[1] == 1; diff --git a/src/Rtmp/RtmpPlayer.cpp b/src/Rtmp/RtmpPlayer.cpp index 9de1c1c2..b699506c 100644 --- a/src/Rtmp/RtmpPlayer.cpp +++ b/src/Rtmp/RtmpPlayer.cpp @@ -311,7 +311,7 @@ void RtmpPlayer::onRtmpChunk(RtmpPacket &chunkData) { if (_aNowStampTicker[idx].elapsedTime() > 500) { _aiNowStamp[idx] = chunkData.timeStamp; } - _onMediaData(std::make_shared(chunkData)); + _onMediaData(std::make_shared(std::move(chunkData))); } break; default: diff --git a/src/Rtmp/RtmpSession.cpp b/src/Rtmp/RtmpSession.cpp index f5d8277f..5274b947 100644 --- a/src/Rtmp/RtmpSession.cpp +++ b/src/Rtmp/RtmpSession.cpp @@ -522,7 +522,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) { if(rtmp_modify_stamp){ chunkData.timeStamp = _stampTicker[chunkData.typeId % 2].elapsedTime(); } - _pPublisherSrc->onWrite(std::make_shared(chunkData)); + _pPublisherSrc->onWrite(std::make_shared(std::move(chunkData))); } break; default: