From cf4015ae96309151e74ddfa7b38f37dc87852008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Cervi=C3=B1o?= Date: Thu, 22 Jun 2017 19:01:54 +0200 Subject: [PATCH] Slight optimization in the packet's hot path (#927) --- erizo/src/erizo/WebRtcConnection.cpp | 14 +++++++------- erizo/src/erizo/WebRtcConnection.h | 4 ++-- erizo/src/erizo/pipeline/Handler.h | 4 ++-- erizo/src/erizo/pipeline/HandlerContext-inl.h | 16 ++++++++-------- erizo/src/erizo/pipeline/Pipeline.cpp | 4 ++-- .../src/erizo/rtp/BandwidthEstimationHandler.cpp | 4 ++-- erizo/src/erizo/rtp/FecReceiverHandler.cpp | 2 +- .../erizo/rtp/LayerBitrateCalculationHandler.cpp | 4 ++-- erizo/src/erizo/rtp/LayerDetectorHandler.cpp | 2 +- erizo/src/erizo/rtp/PliPacerHandler.cpp | 4 ++-- erizo/src/erizo/rtp/QualityFilterHandler.cpp | 2 +- .../erizo/rtp/RtcpFeedbackGenerationHandler.cpp | 10 +++++----- erizo/src/erizo/rtp/RtcpProcessorHandler.cpp | 6 +++--- .../src/erizo/rtp/RtpPaddingGeneratorHandler.cpp | 8 ++++---- erizo/src/erizo/rtp/RtpPaddingRemovalHandler.cpp | 8 ++++---- erizo/src/erizo/rtp/RtpRetransmissionHandler.cpp | 4 ++-- erizo/src/erizo/rtp/RtpSlideShowHandler.cpp | 8 ++++---- erizo/src/erizo/rtp/RtpTrackMuteHandler.cpp | 14 +++++++------- erizo/src/erizo/rtp/RtpTrackMuteHandler.h | 2 +- erizo/src/erizo/rtp/SRPacketHandler.cpp | 4 ++-- .../rtp/SenderBandwidthEstimantionHandler.cpp | 4 ++-- erizo/src/erizo/rtp/StatsHandler.cpp | 4 ++-- 22 files changed, 66 insertions(+), 66 deletions(-) diff --git a/erizo/src/erizo/WebRtcConnection.cpp b/erizo/src/erizo/WebRtcConnection.cpp index 88c7a9cf0d..7d92e21684 100644 --- a/erizo/src/erizo/WebRtcConnection.cpp +++ b/erizo/src/erizo/WebRtcConnection.cpp @@ -461,7 +461,7 @@ void WebRtcConnection::onTransportData(std::shared_ptr packet, Trans return; } - pipeline_->read(packet); + pipeline_->read(std::move(packet)); } void WebRtcConnection::read(std::shared_ptr packet) { @@ -480,7 +480,7 @@ void WebRtcConnection::read(std::shared_ptr packet) { // DELIVER FEEDBACK (RR, FEEDBACK PACKETS) if (chead->isFeedback()) { if (fb_sink_ != nullptr && shouldSendFeedback_) { - fb_sink_->deliverFeedback(packet); + fb_sink_->deliverFeedback(std::move(packet)); } } else { // RTP or RTCP Sender Report @@ -489,10 +489,10 @@ void WebRtcConnection::read(std::shared_ptr packet) { // Deliver data if (isVideoSourceSSRC(recvSSRC)) { parseIncomingPayloadType(buf, len, VIDEO_PACKET); - video_sink_->deliverVideoData(packet); + video_sink_->deliverVideoData(std::move(packet)); } else if (isAudioSourceSSRC(recvSSRC)) { parseIncomingPayloadType(buf, len, AUDIO_PACKET); - audio_sink_->deliverAudioData(packet); + audio_sink_->deliverAudioData(std::move(packet)); } else { ELOG_DEBUG("%s unknownSSRC: %u, localVideoSSRC: %u, localAudioSSRC: %u", toLog(), recvSSRC, this->getVideoSourceSSRC(), this->getAudioSourceSSRC()); @@ -505,7 +505,7 @@ void WebRtcConnection::read(std::shared_ptr packet) { ELOG_DEBUG("%s discoveredAudioSourceSSRC:%u", toLog(), recvSSRC); this->setAudioSourceSSRC(recvSSRC); } - audio_sink_->deliverAudioData(packet); + audio_sink_->deliverAudioData(std::move(packet)); } else if (packet->type == VIDEO_PACKET && video_sink_ != nullptr) { parseIncomingPayloadType(buf, len, VIDEO_PACKET); // Firefox does not send SSRC in SDP @@ -514,7 +514,7 @@ void WebRtcConnection::read(std::shared_ptr packet) { this->setVideoSourceSSRC(recvSSRC); } // change ssrc for RTP packets, don't touch here if RTCP - video_sink_->deliverVideoData(packet); + video_sink_->deliverVideoData(std::move(packet)); } } // if not bundle } // if not Feedback @@ -865,7 +865,7 @@ void WebRtcConnection::sendPacket(std::shared_ptr p) { return; } - pipeline_->write(p); + pipeline_->write(std::move(p)); } void WebRtcConnection::setQualityLayer(int spatial_layer, int temporal_layer) { diff --git a/erizo/src/erizo/WebRtcConnection.h b/erizo/src/erizo/WebRtcConnection.h index b0f2fba56b..02d8c14721 100644 --- a/erizo/src/erizo/WebRtcConnection.h +++ b/erizo/src/erizo/WebRtcConnection.h @@ -248,7 +248,7 @@ class PacketReader : public InboundHandler { } void read(Context *ctx, std::shared_ptr packet) override { - connection_->read(packet); + connection_->read(std::move(packet)); } void notifyUpdate() override { @@ -270,7 +270,7 @@ class PacketWriter : public OutboundHandler { } void write(Context *ctx, std::shared_ptr packet) override { - connection_->write(packet); + connection_->write(std::move(packet)); } void notifyUpdate() override { diff --git a/erizo/src/erizo/pipeline/Handler.h b/erizo/src/erizo/pipeline/Handler.h index 037d01fc82..ba0529c00a 100644 --- a/erizo/src/erizo/pipeline/Handler.h +++ b/erizo/src/erizo/pipeline/Handler.h @@ -131,11 +131,11 @@ class HandlerAdapter : public Handler { } void read(Context* ctx, std::shared_ptr packet) override { - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } void write(Context* ctx, std::shared_ptr packet) override { - return ctx->fireWrite(packet); + return ctx->fireWrite(std::move(packet)); } void notifyUpdate() override { diff --git a/erizo/src/erizo/pipeline/HandlerContext-inl.h b/erizo/src/erizo/pipeline/HandlerContext-inl.h index 69b93ddaa3..69aeff14e7 100644 --- a/erizo/src/erizo/pipeline/HandlerContext-inl.h +++ b/erizo/src/erizo/pipeline/HandlerContext-inl.h @@ -169,7 +169,7 @@ class ContextImpl void fireRead(std::shared_ptr packet) override { auto guard = this->pipelineWeak_.lock(); if (this->nextIn_) { - this->nextIn_->read(packet); + this->nextIn_->read(std::move(packet)); } } @@ -197,7 +197,7 @@ class ContextImpl void fireWrite(std::shared_ptr packet) override { auto guard = this->pipelineWeak_.lock(); if (this->nextOut_) { - this->nextOut_->write(packet); + this->nextOut_->write(std::move(packet)); } } @@ -219,7 +219,7 @@ class ContextImpl // InboundLink overrides void read(std::shared_ptr packet) override { auto guard = this->pipelineWeak_.lock(); - this->handler_->read(this, packet); + this->handler_->read(this, std::move(packet)); } void readEOF() override { @@ -240,7 +240,7 @@ class ContextImpl // OutboundLink overrides void write(std::shared_ptr packet) override { auto guard = this->pipelineWeak_.lock(); - this->handler_->write(this, packet); + this->handler_->write(this, std::move(packet)); } void close() override { @@ -275,7 +275,7 @@ class InboundContextImpl void fireRead(std::shared_ptr packet) override { auto guard = this->pipelineWeak_.lock(); if (this->nextIn_) { - this->nextIn_->read(packet); + this->nextIn_->read(std::move(packet)); } } @@ -311,7 +311,7 @@ class InboundContextImpl // InboundLink overrides void read(std::shared_ptr packet) override { auto guard = this->pipelineWeak_.lock(); - this->handler_->read(this, packet); + this->handler_->read(this, std::move(packet)); } void readEOF() override { @@ -356,7 +356,7 @@ class OutboundContextImpl void fireWrite(std::shared_ptr packet) override { auto guard = this->pipelineWeak_.lock(); if (this->nextOut_) { - return this->nextOut_->write(packet); + return this->nextOut_->write(std::move(packet)); } } @@ -378,7 +378,7 @@ class OutboundContextImpl // OutboundLink overrides void write(std::shared_ptr packet) override { auto guard = this->pipelineWeak_.lock(); - return this->handler_->write(this, packet); + return this->handler_->write(this, std::move(packet)); } void close() override { diff --git a/erizo/src/erizo/pipeline/Pipeline.cpp b/erizo/src/erizo/pipeline/Pipeline.cpp index 7819c9eab1..0c894d4b2b 100644 --- a/erizo/src/erizo/pipeline/Pipeline.cpp +++ b/erizo/src/erizo/pipeline/Pipeline.cpp @@ -69,7 +69,7 @@ void Pipeline::read(std::shared_ptr packet) { if (!front_) { return; } - front_->read(packet); + front_->read(std::move(packet)); } void Pipeline::readEOF() { @@ -83,7 +83,7 @@ void Pipeline::write(std::shared_ptr packet) { if (!back_) { return; } - back_->write(packet); + back_->write(std::move(packet)); } void Pipeline::close() { diff --git a/erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp b/erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp index f1238c185d..2418f032be 100644 --- a/erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp +++ b/erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp @@ -146,7 +146,7 @@ void BandwidthEstimationHandler::read(Context *ctx, std::shared_ptr ELOG_DEBUG("Packet not parsed %d", packet->type); } } - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } bool BandwidthEstimationHandler::parsePacket(std::shared_ptr packet) { @@ -175,7 +175,7 @@ RtpHeaderExtensionMap BandwidthEstimationHandler::getHeaderExtensionMap(std::sha } void BandwidthEstimationHandler::write(Context *ctx, std::shared_ptr packet) { - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } void BandwidthEstimationHandler::pickEstimatorFromHeader() { diff --git a/erizo/src/erizo/rtp/FecReceiverHandler.cpp b/erizo/src/erizo/rtp/FecReceiverHandler.cpp index d9bbfd1aa1..2330146e18 100644 --- a/erizo/src/erizo/rtp/FecReceiverHandler.cpp +++ b/erizo/src/erizo/rtp/FecReceiverHandler.cpp @@ -60,7 +60,7 @@ void FecReceiverHandler::write(Context *ctx, std::shared_ptr packet) } } - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } bool FecReceiverHandler::OnRecoveredPacket(const uint8_t* rtp_packet, size_t rtp_packet_length) { diff --git a/erizo/src/erizo/rtp/LayerBitrateCalculationHandler.cpp b/erizo/src/erizo/rtp/LayerBitrateCalculationHandler.cpp index 82de64d141..d1a538cdd3 100644 --- a/erizo/src/erizo/rtp/LayerBitrateCalculationHandler.cpp +++ b/erizo/src/erizo/rtp/LayerBitrateCalculationHandler.cpp @@ -22,7 +22,7 @@ void LayerBitrateCalculationHandler::disable() { void LayerBitrateCalculationHandler::write(Context *ctx, std::shared_ptr packet) { if (!enabled_ || !initialized_) { - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); return; } @@ -42,7 +42,7 @@ void LayerBitrateCalculationHandler::write(Context *ctx, std::shared_ptrnotifyQualityUpdate(); - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } diff --git a/erizo/src/erizo/rtp/LayerDetectorHandler.cpp b/erizo/src/erizo/rtp/LayerDetectorHandler.cpp index a0d547339f..791aa140cd 100644 --- a/erizo/src/erizo/rtp/LayerDetectorHandler.cpp +++ b/erizo/src/erizo/rtp/LayerDetectorHandler.cpp @@ -30,7 +30,7 @@ void LayerDetectorHandler::read(Context *ctx, std::shared_ptr packet parseLayerInfoFromVP9(packet); } } - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } int LayerDetectorHandler::getSsrcPosition(uint32_t ssrc) { diff --git a/erizo/src/erizo/rtp/PliPacerHandler.cpp b/erizo/src/erizo/rtp/PliPacerHandler.cpp index 7c4296f010..9afaef7a34 100644 --- a/erizo/src/erizo/rtp/PliPacerHandler.cpp +++ b/erizo/src/erizo/rtp/PliPacerHandler.cpp @@ -40,7 +40,7 @@ void PliPacerHandler::read(Context *ctx, std::shared_ptr packet) { connection_->getWorker()->unschedule(scheduled_pli_); scheduled_pli_ = -1; } - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } void PliPacerHandler::sendPLI() { @@ -81,7 +81,7 @@ void PliPacerHandler::write(Context *ctx, std::shared_ptr packet) { waiting_for_keyframe_ = true; scheduleNextPLI(); } - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } } // namespace erizo diff --git a/erizo/src/erizo/rtp/QualityFilterHandler.cpp b/erizo/src/erizo/rtp/QualityFilterHandler.cpp index a1012c05f0..5e4188010f 100644 --- a/erizo/src/erizo/rtp/QualityFilterHandler.cpp +++ b/erizo/src/erizo/rtp/QualityFilterHandler.cpp @@ -44,7 +44,7 @@ void QualityFilterHandler::read(Context *ctx, std::shared_ptr packet return; } - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } void QualityFilterHandler::checkLayers() { diff --git a/erizo/src/erizo/rtp/RtcpFeedbackGenerationHandler.cpp b/erizo/src/erizo/rtp/RtcpFeedbackGenerationHandler.cpp index 902244d501..cee3765998 100644 --- a/erizo/src/erizo/rtp/RtcpFeedbackGenerationHandler.cpp +++ b/erizo/src/erizo/rtp/RtcpFeedbackGenerationHandler.cpp @@ -22,7 +22,7 @@ void RtcpFeedbackGenerationHandler::read(Context *ctx, std::shared_ptr(packet->data); if (!initialized_) { - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); return; } @@ -34,7 +34,7 @@ void RtcpFeedbackGenerationHandler::read(Context *ctx, std::shared_ptrfireRead(packet); + ctx->fireRead(std::move(packet)); return; } bool should_send_rr = false; @@ -59,14 +59,14 @@ void RtcpFeedbackGenerationHandler::read(Context *ctx, std::shared_ptrsecond->nack_generator != nullptr) { generator_it->second->nack_generator->addNackPacketToRr(rtcp_packet); } - ctx->fireWrite(rtcp_packet); + ctx->fireWrite(std::move(rtcp_packet)); } } - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } void RtcpFeedbackGenerationHandler::write(Context *ctx, std::shared_ptr packet) { - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } void RtcpFeedbackGenerationHandler::notifyUpdate() { diff --git a/erizo/src/erizo/rtp/RtcpProcessorHandler.cpp b/erizo/src/erizo/rtp/RtcpProcessorHandler.cpp index 2e9f56aabb..ac6f37facf 100644 --- a/erizo/src/erizo/rtp/RtcpProcessorHandler.cpp +++ b/erizo/src/erizo/rtp/RtcpProcessorHandler.cpp @@ -27,7 +27,7 @@ void RtcpProcessorHandler::read(Context *ctx, std::shared_ptr packet } } processor_->checkRtcpFb(); - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } void RtcpProcessorHandler::write(Context *ctx, std::shared_ptr packet) { @@ -35,11 +35,11 @@ void RtcpProcessorHandler::write(Context *ctx, std::shared_ptr packe if (chead->isFeedback()) { int length = processor_->analyzeFeedback(packet->data, packet->length); if (length) { - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } return; } - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } void RtcpProcessorHandler::notifyUpdate() { diff --git a/erizo/src/erizo/rtp/RtpPaddingGeneratorHandler.cpp b/erizo/src/erizo/rtp/RtpPaddingGeneratorHandler.cpp index 7ae8d1edfd..b018210fa8 100644 --- a/erizo/src/erizo/rtp/RtpPaddingGeneratorHandler.cpp +++ b/erizo/src/erizo/rtp/RtpPaddingGeneratorHandler.cpp @@ -62,7 +62,7 @@ void RtpPaddingGeneratorHandler::notifyUpdate() { } void RtpPaddingGeneratorHandler::read(Context *ctx, std::shared_ptr packet) { - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } void RtpPaddingGeneratorHandler::write(Context *ctx, std::shared_ptr packet) { @@ -80,7 +80,7 @@ void RtpPaddingGeneratorHandler::write(Context *ctx, std::shared_ptr ctx->fireWrite(packet); if (is_higher_sequence_number) { - onVideoPacket(packet); + onVideoPacket(std::move(packet)); } } @@ -101,7 +101,7 @@ void RtpPaddingGeneratorHandler::sendPaddingPacket(std::shared_ptr p rtp_header->setSeqNumber(sequence_number.output); stats_->getNode()["total"]["paddingBitrate"] += padding_packet->length; - getContext()->fireWrite(padding_packet); + getContext()->fireWrite(std::move(padding_packet)); } void RtpPaddingGeneratorHandler::onPacketWithMarkerSet(std::shared_ptr packet) { @@ -141,7 +141,7 @@ void RtpPaddingGeneratorHandler::onVideoPacket(std::shared_ptr packe RtpHeader *rtp_header = reinterpret_cast(packet->data); if (rtp_header->getMarker()) { - onPacketWithMarkerSet(packet); + onPacketWithMarkerSet(std::move(packet)); } } diff --git a/erizo/src/erizo/rtp/RtpPaddingRemovalHandler.cpp b/erizo/src/erizo/rtp/RtpPaddingRemovalHandler.cpp index b85d39b96d..21cf8374a9 100644 --- a/erizo/src/erizo/rtp/RtpPaddingRemovalHandler.cpp +++ b/erizo/src/erizo/rtp/RtpPaddingRemovalHandler.cpp @@ -37,20 +37,20 @@ void RtpPaddingRemovalHandler::read(Context *ctx, std::shared_ptr pa ssrc); rtp_header->setSeqNumber(sequence_number_info.output); } - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } void RtpPaddingRemovalHandler::write(Context *ctx, std::shared_ptr packet) { RtcpHeader* rtcp_head = reinterpret_cast(packet->data); if (!enabled_ || packet->type != VIDEO_PACKET || !rtcp_head->isFeedback()) { - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); return; } uint32_t ssrc = rtcp_head->getSourceSSRC(); std::shared_ptr translator = getTranslatorForSsrc(ssrc, false); if (!translator) { ELOG_DEBUG("No translator for ssrc %u, %s", ssrc, connection_->toLog()); - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); return; } RtpUtils::forEachRRBlock(packet, [this, translator, ssrc](RtcpHeader *chead) { @@ -83,7 +83,7 @@ void RtpPaddingRemovalHandler::write(Context *ctx, std::shared_ptr p }); } }); - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } bool RtpPaddingRemovalHandler::removePaddingBytes(std::shared_ptr packet, diff --git a/erizo/src/erizo/rtp/RtpRetransmissionHandler.cpp b/erizo/src/erizo/rtp/RtpRetransmissionHandler.cpp index bb2621a8ef..9af5f8cbbc 100644 --- a/erizo/src/erizo/rtp/RtpRetransmissionHandler.cpp +++ b/erizo/src/erizo/rtp/RtpRetransmissionHandler.cpp @@ -111,7 +111,7 @@ void RtpRetransmissionHandler::read(Context *ctx, std::shared_ptr pa } }); if (!contains_nack || !is_fully_recovered) { - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } } @@ -123,7 +123,7 @@ void RtpRetransmissionHandler::write(Context *ctx, std::shared_ptr p if (!chead->isRtcp()) { packet_buffer_->insertPacket(packet); } - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } } // namespace erizo diff --git a/erizo/src/erizo/rtp/RtpSlideShowHandler.cpp b/erizo/src/erizo/rtp/RtpSlideShowHandler.cpp index 45d2a50f9c..f68d222d46 100644 --- a/erizo/src/erizo/rtp/RtpSlideShowHandler.cpp +++ b/erizo/src/erizo/rtp/RtpSlideShowHandler.cpp @@ -47,7 +47,7 @@ void RtpSlideShowHandler::notifyUpdate() { void RtpSlideShowHandler::read(Context *ctx, std::shared_ptr packet) { RtcpHeader *chead = reinterpret_cast(packet->data); if (connection_->getVideoSinkSSRC() != chead->getSourceSSRC()) { - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); return; } RtpUtils::forEachRRBlock(packet, [this](RtcpHeader *chead) { @@ -78,14 +78,14 @@ void RtpSlideShowHandler::read(Context *ctx, std::shared_ptr packet) break; } }); - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } void RtpSlideShowHandler::write(Context *ctx, std::shared_ptr packet) { RtpHeader *rtp_header = reinterpret_cast(packet->data); RtcpHeader *rtcp_header = reinterpret_cast(packet->data); if (packet->type != VIDEO_PACKET || rtcp_header->isRtcp()) { - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); return; } bool should_skip_packet = false; @@ -118,7 +118,7 @@ void RtpSlideShowHandler::write(Context *ctx, std::shared_ptr packet rtp_header->setSeqNumber(sequence_number_info.output); ELOG_DEBUG("SN %u %d", sequence_number_info.output, is_keyframe); last_keyframe_sent_time_ = clock_->now(); - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } } diff --git a/erizo/src/erizo/rtp/RtpTrackMuteHandler.cpp b/erizo/src/erizo/rtp/RtpTrackMuteHandler.cpp index d385e95eb4..969fd23ddc 100644 --- a/erizo/src/erizo/rtp/RtpTrackMuteHandler.cpp +++ b/erizo/src/erizo/rtp/RtpTrackMuteHandler.cpp @@ -33,10 +33,10 @@ void RtpTrackMuteHandler::read(Context *ctx, std::shared_ptr packet) handleFeedback(video_info_, packet); } - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } -void RtpTrackMuteHandler::handleFeedback(const TrackMuteInfo &info, std::shared_ptr packet) { +void RtpTrackMuteHandler::handleFeedback(const TrackMuteInfo &info, const std::shared_ptr &packet) { RtcpHeader *chead = reinterpret_cast(packet->data); uint16_t offset = info.seq_num_offset; if (offset > 0) { @@ -71,13 +71,13 @@ void RtpTrackMuteHandler::handleFeedback(const TrackMuteInfo &info, std::shared_ void RtpTrackMuteHandler::write(Context *ctx, std::shared_ptr packet) { RtcpHeader *rtcp_header = reinterpret_cast(packet->data); if (rtcp_header->isRtcp()) { - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } else if (packet->type == AUDIO_PACKET) { - handlePacket(ctx, &audio_info_, packet); + handlePacket(ctx, &audio_info_, std::move(packet)); } else if (packet->type == VIDEO_PACKET) { - handlePacket(ctx, &video_info_, packet); + handlePacket(ctx, &video_info_, std::move(packet)); } else { - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } } @@ -90,7 +90,7 @@ void RtpTrackMuteHandler::handlePacket(Context *ctx, TrackMuteInfo *info, std::s if (offset > 0) { setPacketSeqNumber(packet, info->last_sent_seq_num); } - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } } diff --git a/erizo/src/erizo/rtp/RtpTrackMuteHandler.h b/erizo/src/erizo/rtp/RtpTrackMuteHandler.h index d86536d603..7dbca943e7 100644 --- a/erizo/src/erizo/rtp/RtpTrackMuteHandler.h +++ b/erizo/src/erizo/rtp/RtpTrackMuteHandler.h @@ -43,7 +43,7 @@ class RtpTrackMuteHandler: public Handler { private: void muteTrack(TrackMuteInfo *info, bool active); - void handleFeedback(const TrackMuteInfo &info, std::shared_ptr packet); + void handleFeedback(const TrackMuteInfo &info, const std::shared_ptr &packet); void handlePacket(Context *ctx, TrackMuteInfo *info, std::shared_ptr packet); inline void setPacketSeqNumber(std::shared_ptr packet, uint16_t seq_number); diff --git a/erizo/src/erizo/rtp/SRPacketHandler.cpp b/erizo/src/erizo/rtp/SRPacketHandler.cpp index eb08e23a6c..ff6de82a72 100644 --- a/erizo/src/erizo/rtp/SRPacketHandler.cpp +++ b/erizo/src/erizo/rtp/SRPacketHandler.cpp @@ -60,11 +60,11 @@ void SRPacketHandler::write(Context *ctx, std::shared_ptr packet) { handleSR(packet); } } - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } void SRPacketHandler::read(Context *ctx, std::shared_ptr packet) { - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } void SRPacketHandler::notifyUpdate() { diff --git a/erizo/src/erizo/rtp/SenderBandwidthEstimantionHandler.cpp b/erizo/src/erizo/rtp/SenderBandwidthEstimantionHandler.cpp index 8d678b1c94..915c2812b7 100644 --- a/erizo/src/erizo/rtp/SenderBandwidthEstimantionHandler.cpp +++ b/erizo/src/erizo/rtp/SenderBandwidthEstimantionHandler.cpp @@ -130,7 +130,7 @@ void SenderBandwidthEstimationHandler::read(Context *ctx, std::shared_ptrlength); } - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } void SenderBandwidthEstimationHandler::write(Context *ctx, std::shared_ptr packet) { @@ -147,7 +147,7 @@ void SenderBandwidthEstimationHandler::write(Context *ctx, std::shared_ptrgetSSRC() == connection_->getVideoSinkSSRC()) { analyzeSr(chead); } - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } void SenderBandwidthEstimationHandler::analyzeSr(RtcpHeader* chead) { diff --git a/erizo/src/erizo/rtp/StatsHandler.cpp b/erizo/src/erizo/rtp/StatsHandler.cpp index 1a220bf9cb..096041b8a5 100644 --- a/erizo/src/erizo/rtp/StatsHandler.cpp +++ b/erizo/src/erizo/rtp/StatsHandler.cpp @@ -188,7 +188,7 @@ void IncomingStatsHandler::notifyUpdate() { void IncomingStatsHandler::read(Context *ctx, std::shared_ptr packet) { processPacket(packet); - ctx->fireRead(packet); + ctx->fireRead(std::move(packet)); } OutgoingStatsHandler::OutgoingStatsHandler() : connection_{nullptr} {} @@ -208,7 +208,7 @@ void OutgoingStatsHandler::notifyUpdate() { void OutgoingStatsHandler::write(Context *ctx, std::shared_ptr packet) { processPacket(packet); - ctx->fireWrite(packet); + ctx->fireWrite(std::move(packet)); } } // namespace erizo