Skip to content

Commit

Permalink
worker: disable RtcLogger usage if not enabled (#1264)
Browse files Browse the repository at this point in the history
worker: disable RtcLogger usage if not enabled
  • Loading branch information
jmillan committed Dec 14, 2023
1 parent 32c37ff commit fb83d4f
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog


### NEXT

* worker: Disable RtcLogger usage if not enabled ([PR #1264](https://github.com/versatica/mediasoup/pull/1264)).


### 3.13.11

* liburing: Avoid extra memcpy on RTP ([PR #1258](https://github.com/versatica/mediasoup/pull/1258)).
Expand Down
4 changes: 4 additions & 0 deletions worker/include/RTC/RtpPacket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "Utils.hpp"
#include "FBS/rtpPacket.h"
#include "RTC/Codecs/PayloadDescriptorHandler.hpp"
#ifdef MS_RTC_LOGGER_RTP
#include "RTC/RtcLogger.hpp"
#endif
#include <flatbuffers/flatbuffers.h>
#include <absl/container/flat_hash_map.h>
#include <array>
Expand Down Expand Up @@ -649,8 +651,10 @@ namespace RTC

void ShiftPayload(size_t payloadOffset, size_t shift, bool expand = true);

#ifdef MS_RTC_LOGGER_RTP
public:
RtcLogger::RtpPacket logger;
#endif

private:
void ParseExtensions();
Expand Down
10 changes: 10 additions & 0 deletions worker/src/RTC/PipeConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,15 @@ namespace RTC
{
MS_TRACE();

#ifdef MS_RTC_LOGGER_RTP
packet->logger.consumerId = this->id;
#endif

if (!IsActive())
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
#endif

return;
}
Expand All @@ -236,7 +240,9 @@ namespace RTC
{
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
#endif

return;
}
Expand All @@ -250,7 +256,9 @@ namespace RTC
// the packet.
if (syncRequired && this->keyFrameSupported && !packet->IsKeyFrame())
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
#endif

return;
}
Expand Down Expand Up @@ -284,8 +292,10 @@ namespace RTC
packet->SetSsrc(ssrc);
packet->SetSequenceNumber(seq);

#ifdef MS_RTC_LOGGER_RTP
packet->logger.sendRtpTimestamp = packet->GetTimestamp();
packet->logger.sendSeqNumber = seq;
#endif

if (isSyncPacket)
{
Expand Down
8 changes: 8 additions & 0 deletions worker/src/RTC/Producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ namespace RTC
{
MS_TRACE();

#ifdef MS_RTC_LOGGER_RTP
packet->logger.producerId = this->id;
#endif

// Reset current packet.
this->currentRtpPacket = nullptr;
Expand All @@ -576,7 +578,9 @@ namespace RTC
{
MS_WARN_TAG(rtp, "no stream found for received packet [ssrc:%" PRIu32 "]", packet->GetSsrc());

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_NOT_FOUND);
#endif

return ReceiveRtpPacketResult::DISCARDED;
}
Expand All @@ -601,7 +605,9 @@ namespace RTC
NotifyNewRtpStream(rtpStream);
}

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_DISCARDED);
#endif

return result;
}
Expand All @@ -615,7 +621,9 @@ namespace RTC
// Process the packet.
if (!rtpStream->ReceiveRtxPacket(packet))
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_NOT_FOUND);
#endif

return result;
}
Expand Down
2 changes: 2 additions & 0 deletions worker/src/RTC/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,9 @@ namespace RTC
{
MS_TRACE();

#ifdef MS_RTC_LOGGER_RTP
packet->logger.routerId = this->id;
#endif

auto& consumers = this->mapProducerConsumers.at(producer);

Expand Down
2 changes: 0 additions & 2 deletions worker/src/RTC/RtcLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ namespace RTC

void RtpPacket::Log() const
{
#ifdef MS_RTC_LOGGER_RTP
MS_TRACE();

std::cout << "{";
Expand Down Expand Up @@ -83,7 +82,6 @@ namespace RTC
std::cout << ", \"dropped\": " << (this->dropped ? "true" : "false");
std::cout << ", \"dropReason\": '" << dropReason2String[this->dropReason] << "'";
std::cout << "}" << std::endl;
#endif
}

void RtpPacket::Clear()
Expand Down
12 changes: 12 additions & 0 deletions worker/src/RTC/SimpleConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,15 @@ namespace RTC
{
MS_TRACE();

#ifdef MS_RTC_LOGGER_RTP
packet->logger.consumerId = this->id;
#endif

if (!IsActive())
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
#endif

return;
}
Expand All @@ -318,7 +322,9 @@ namespace RTC
{
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
#endif

return;
}
Expand All @@ -336,7 +342,9 @@ namespace RTC

this->rtpSeqManager.Drop(packet->GetSequenceNumber());

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC);
#endif

return;
}
Expand All @@ -345,7 +353,9 @@ namespace RTC
// the packet.
if (this->syncRequired && this->keyFrameSupported && !packet->IsKeyFrame())
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
#endif

return;
}
Expand Down Expand Up @@ -379,8 +389,10 @@ namespace RTC
packet->SetSsrc(this->rtpParameters.encodings[0].ssrc);
packet->SetSequenceNumber(seq);

#ifdef MS_RTC_LOGGER_RTP
packet->logger.sendRtpTimestamp = packet->GetTimestamp();
packet->logger.sendSeqNumber = seq;
#endif

if (isSyncPacket)
{
Expand Down
24 changes: 24 additions & 0 deletions worker/src/RTC/SimulcastConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,18 +712,24 @@ namespace RTC
{
MS_TRACE();

#ifdef MS_RTC_LOGGER_RTP
packet->logger.consumerId = this->id;
#endif

if (!IsActive())
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
#endif

return;
}

if (this->targetTemporalLayer == -1)
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::INVALID_TARGET_LAYER);
#endif

return;
}
Expand All @@ -736,7 +742,9 @@ namespace RTC
{
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
#endif

return;
}
Expand All @@ -751,7 +759,9 @@ namespace RTC
// Ignore if not a key frame.
if (!packet->IsKeyFrame())
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
#endif

return;
}
Expand All @@ -766,15 +776,19 @@ namespace RTC
// drop it.
else if (spatialLayer != this->currentSpatialLayer)
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::SPATIAL_LAYER_MISMATCH);
#endif

return;
}

// If we need to sync and this is not a key frame, ignore the packet.
if (this->syncRequired && !packet->IsKeyFrame())
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
#endif

return;
}
Expand Down Expand Up @@ -890,7 +904,9 @@ namespace RTC
this->syncRequired = false;
this->spatialLayerToSync = -1;

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::TOO_HIGH_TIMESTAMP_EXTRA_NEEDED);
#endif

return;
}
Expand Down Expand Up @@ -932,8 +948,10 @@ namespace RTC
if (SeqManager<uint16_t>::IsSeqLowerThan(
packet->GetSequenceNumber(), this->snReferenceSpatialLayer))
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(
RtcLogger::RtpPacket::DropReason::PACKET_PREVIOUS_TO_SPATIAL_LAYER_SWITCH);
#endif

return;
}
Expand Down Expand Up @@ -979,7 +997,9 @@ namespace RTC
{
this->rtpSeqManager.Drop(packet->GetSequenceNumber());

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC);
#endif

return;
}
Expand All @@ -1006,8 +1026,10 @@ namespace RTC
packet->SetSequenceNumber(seq);
packet->SetTimestamp(timestamp);

#ifdef MS_RTC_LOGGER_RTP
packet->logger.sendRtpTimestamp = timestamp;
packet->logger.sendSeqNumber = seq;
#endif

if (isSyncPacket)
{
Expand Down Expand Up @@ -1050,7 +1072,9 @@ namespace RTC
origSeq,
origTimestamp);

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::SEND_RTP_STREAM_DISCARDED);
#endif
}

// Restore packet fields.
Expand Down
14 changes: 14 additions & 0 deletions worker/src/RTC/SvcConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,15 @@ namespace RTC
{
MS_TRACE();

#ifdef MS_RTC_LOGGER_RTP
packet->logger.consumerId = this->id;
#endif

if (!IsActive())
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
#endif

return;
}
Expand All @@ -643,7 +647,9 @@ namespace RTC
)
// clang-format on
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::INVALID_TARGET_LAYER);
#endif

return;
}
Expand All @@ -656,15 +662,19 @@ namespace RTC
{
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
#endif

return;
}

// If we need to sync and this is not a key frame, ignore the packet.
if (this->syncRequired && !packet->IsKeyFrame())
{
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
#endif

return;
}
Expand Down Expand Up @@ -696,7 +706,9 @@ namespace RTC
{
this->rtpSeqManager.Drop(packet->GetSequenceNumber());

#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC);
#endif

return;
}
Expand Down Expand Up @@ -725,8 +737,10 @@ namespace RTC
packet->SetSsrc(this->rtpParameters.encodings[0].ssrc);
packet->SetSequenceNumber(seq);

#ifdef MS_RTC_LOGGER_RTP
packet->logger.sendRtpTimestamp = packet->GetTimestamp();
packet->logger.sendSeqNumber = seq;
#endif

if (marker)
{
Expand Down

0 comments on commit fb83d4f

Please sign in to comment.