Unverified 提交 fb83d4f4 authored 作者: José Luis Millán's avatar José Luis Millán 提交者: GitHub

worker: disable RtcLogger usage if not enabled (#1264)

worker: disable RtcLogger usage if not enabled
上级 32c37ff1
# Changelog # Changelog
### NEXT
* worker: Disable RtcLogger usage if not enabled ([PR #1264](https://github.com/versatica/mediasoup/pull/1264)).
### 3.13.11 ### 3.13.11
* liburing: Avoid extra memcpy on RTP ([PR #1258](https://github.com/versatica/mediasoup/pull/1258)). * liburing: Avoid extra memcpy on RTP ([PR #1258](https://github.com/versatica/mediasoup/pull/1258)).
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
#include "Utils.hpp" #include "Utils.hpp"
#include "FBS/rtpPacket.h" #include "FBS/rtpPacket.h"
#include "RTC/Codecs/PayloadDescriptorHandler.hpp" #include "RTC/Codecs/PayloadDescriptorHandler.hpp"
#ifdef MS_RTC_LOGGER_RTP
#include "RTC/RtcLogger.hpp" #include "RTC/RtcLogger.hpp"
#endif
#include <flatbuffers/flatbuffers.h> #include <flatbuffers/flatbuffers.h>
#include <absl/container/flat_hash_map.h> #include <absl/container/flat_hash_map.h>
#include <array> #include <array>
...@@ -649,8 +651,10 @@ namespace RTC ...@@ -649,8 +651,10 @@ namespace RTC
void ShiftPayload(size_t payloadOffset, size_t shift, bool expand = true); void ShiftPayload(size_t payloadOffset, size_t shift, bool expand = true);
#ifdef MS_RTC_LOGGER_RTP
public: public:
RtcLogger::RtpPacket logger; RtcLogger::RtpPacket logger;
#endif
private: private:
void ParseExtensions(); void ParseExtensions();
......
...@@ -219,11 +219,15 @@ namespace RTC ...@@ -219,11 +219,15 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
#ifdef MS_RTC_LOGGER_RTP
packet->logger.consumerId = this->id; packet->logger.consumerId = this->id;
#endif
if (!IsActive()) if (!IsActive())
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
#endif
return; return;
} }
...@@ -236,7 +240,9 @@ namespace RTC ...@@ -236,7 +240,9 @@ namespace RTC
{ {
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType); MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
#endif
return; return;
} }
...@@ -250,7 +256,9 @@ namespace RTC ...@@ -250,7 +256,9 @@ namespace RTC
// the packet. // the packet.
if (syncRequired && this->keyFrameSupported && !packet->IsKeyFrame()) if (syncRequired && this->keyFrameSupported && !packet->IsKeyFrame())
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
#endif
return; return;
} }
...@@ -284,8 +292,10 @@ namespace RTC ...@@ -284,8 +292,10 @@ namespace RTC
packet->SetSsrc(ssrc); packet->SetSsrc(ssrc);
packet->SetSequenceNumber(seq); packet->SetSequenceNumber(seq);
#ifdef MS_RTC_LOGGER_RTP
packet->logger.sendRtpTimestamp = packet->GetTimestamp(); packet->logger.sendRtpTimestamp = packet->GetTimestamp();
packet->logger.sendSeqNumber = seq; packet->logger.sendSeqNumber = seq;
#endif
if (isSyncPacket) if (isSyncPacket)
{ {
......
...@@ -562,7 +562,9 @@ namespace RTC ...@@ -562,7 +562,9 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
#ifdef MS_RTC_LOGGER_RTP
packet->logger.producerId = this->id; packet->logger.producerId = this->id;
#endif
// Reset current packet. // Reset current packet.
this->currentRtpPacket = nullptr; this->currentRtpPacket = nullptr;
...@@ -576,7 +578,9 @@ namespace RTC ...@@ -576,7 +578,9 @@ namespace RTC
{ {
MS_WARN_TAG(rtp, "no stream found for received packet [ssrc:%" PRIu32 "]", packet->GetSsrc()); 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); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_NOT_FOUND);
#endif
return ReceiveRtpPacketResult::DISCARDED; return ReceiveRtpPacketResult::DISCARDED;
} }
...@@ -601,7 +605,9 @@ namespace RTC ...@@ -601,7 +605,9 @@ namespace RTC
NotifyNewRtpStream(rtpStream); NotifyNewRtpStream(rtpStream);
} }
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_DISCARDED); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_DISCARDED);
#endif
return result; return result;
} }
...@@ -615,7 +621,9 @@ namespace RTC ...@@ -615,7 +621,9 @@ namespace RTC
// Process the packet. // Process the packet.
if (!rtpStream->ReceiveRtxPacket(packet)) if (!rtpStream->ReceiveRtxPacket(packet))
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_NOT_FOUND); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_NOT_FOUND);
#endif
return result; return result;
} }
......
...@@ -652,7 +652,9 @@ namespace RTC ...@@ -652,7 +652,9 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
#ifdef MS_RTC_LOGGER_RTP
packet->logger.routerId = this->id; packet->logger.routerId = this->id;
#endif
auto& consumers = this->mapProducerConsumers.at(producer); auto& consumers = this->mapProducerConsumers.at(producer);
......
...@@ -49,7 +49,6 @@ namespace RTC ...@@ -49,7 +49,6 @@ namespace RTC
void RtpPacket::Log() const void RtpPacket::Log() const
{ {
#ifdef MS_RTC_LOGGER_RTP
MS_TRACE(); MS_TRACE();
std::cout << "{"; std::cout << "{";
...@@ -83,7 +82,6 @@ namespace RTC ...@@ -83,7 +82,6 @@ namespace RTC
std::cout << ", \"dropped\": " << (this->dropped ? "true" : "false"); std::cout << ", \"dropped\": " << (this->dropped ? "true" : "false");
std::cout << ", \"dropReason\": '" << dropReason2String[this->dropReason] << "'"; std::cout << ", \"dropReason\": '" << dropReason2String[this->dropReason] << "'";
std::cout << "}" << std::endl; std::cout << "}" << std::endl;
#endif
} }
void RtpPacket::Clear() void RtpPacket::Clear()
......
...@@ -301,11 +301,15 @@ namespace RTC ...@@ -301,11 +301,15 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
#ifdef MS_RTC_LOGGER_RTP
packet->logger.consumerId = this->id; packet->logger.consumerId = this->id;
#endif
if (!IsActive()) if (!IsActive())
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
#endif
return; return;
} }
...@@ -318,7 +322,9 @@ namespace RTC ...@@ -318,7 +322,9 @@ namespace RTC
{ {
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType); MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
#endif
return; return;
} }
...@@ -336,7 +342,9 @@ namespace RTC ...@@ -336,7 +342,9 @@ namespace RTC
this->rtpSeqManager.Drop(packet->GetSequenceNumber()); this->rtpSeqManager.Drop(packet->GetSequenceNumber());
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC);
#endif
return; return;
} }
...@@ -345,7 +353,9 @@ namespace RTC ...@@ -345,7 +353,9 @@ namespace RTC
// the packet. // the packet.
if (this->syncRequired && this->keyFrameSupported && !packet->IsKeyFrame()) if (this->syncRequired && this->keyFrameSupported && !packet->IsKeyFrame())
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
#endif
return; return;
} }
...@@ -379,8 +389,10 @@ namespace RTC ...@@ -379,8 +389,10 @@ namespace RTC
packet->SetSsrc(this->rtpParameters.encodings[0].ssrc); packet->SetSsrc(this->rtpParameters.encodings[0].ssrc);
packet->SetSequenceNumber(seq); packet->SetSequenceNumber(seq);
#ifdef MS_RTC_LOGGER_RTP
packet->logger.sendRtpTimestamp = packet->GetTimestamp(); packet->logger.sendRtpTimestamp = packet->GetTimestamp();
packet->logger.sendSeqNumber = seq; packet->logger.sendSeqNumber = seq;
#endif
if (isSyncPacket) if (isSyncPacket)
{ {
......
...@@ -712,18 +712,24 @@ namespace RTC ...@@ -712,18 +712,24 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
#ifdef MS_RTC_LOGGER_RTP
packet->logger.consumerId = this->id; packet->logger.consumerId = this->id;
#endif
if (!IsActive()) if (!IsActive())
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
#endif
return; return;
} }
if (this->targetTemporalLayer == -1) if (this->targetTemporalLayer == -1)
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::INVALID_TARGET_LAYER); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::INVALID_TARGET_LAYER);
#endif
return; return;
} }
...@@ -736,7 +742,9 @@ namespace RTC ...@@ -736,7 +742,9 @@ namespace RTC
{ {
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType); MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
#endif
return; return;
} }
...@@ -751,7 +759,9 @@ namespace RTC ...@@ -751,7 +759,9 @@ namespace RTC
// Ignore if not a key frame. // Ignore if not a key frame.
if (!packet->IsKeyFrame()) if (!packet->IsKeyFrame())
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
#endif
return; return;
} }
...@@ -766,7 +776,9 @@ namespace RTC ...@@ -766,7 +776,9 @@ namespace RTC
// drop it. // drop it.
else if (spatialLayer != this->currentSpatialLayer) else if (spatialLayer != this->currentSpatialLayer)
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::SPATIAL_LAYER_MISMATCH); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::SPATIAL_LAYER_MISMATCH);
#endif
return; return;
} }
...@@ -774,7 +786,9 @@ namespace RTC ...@@ -774,7 +786,9 @@ namespace RTC
// If we need to sync and this is not a key frame, ignore the packet. // If we need to sync and this is not a key frame, ignore the packet.
if (this->syncRequired && !packet->IsKeyFrame()) if (this->syncRequired && !packet->IsKeyFrame())
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
#endif
return; return;
} }
...@@ -890,7 +904,9 @@ namespace RTC ...@@ -890,7 +904,9 @@ namespace RTC
this->syncRequired = false; this->syncRequired = false;
this->spatialLayerToSync = -1; this->spatialLayerToSync = -1;
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::TOO_HIGH_TIMESTAMP_EXTRA_NEEDED); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::TOO_HIGH_TIMESTAMP_EXTRA_NEEDED);
#endif
return; return;
} }
...@@ -932,8 +948,10 @@ namespace RTC ...@@ -932,8 +948,10 @@ namespace RTC
if (SeqManager<uint16_t>::IsSeqLowerThan( if (SeqManager<uint16_t>::IsSeqLowerThan(
packet->GetSequenceNumber(), this->snReferenceSpatialLayer)) packet->GetSequenceNumber(), this->snReferenceSpatialLayer))
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped( packet->logger.Dropped(
RtcLogger::RtpPacket::DropReason::PACKET_PREVIOUS_TO_SPATIAL_LAYER_SWITCH); RtcLogger::RtpPacket::DropReason::PACKET_PREVIOUS_TO_SPATIAL_LAYER_SWITCH);
#endif
return; return;
} }
...@@ -979,7 +997,9 @@ namespace RTC ...@@ -979,7 +997,9 @@ namespace RTC
{ {
this->rtpSeqManager.Drop(packet->GetSequenceNumber()); this->rtpSeqManager.Drop(packet->GetSequenceNumber());
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC);
#endif
return; return;
} }
...@@ -1006,8 +1026,10 @@ namespace RTC ...@@ -1006,8 +1026,10 @@ namespace RTC
packet->SetSequenceNumber(seq); packet->SetSequenceNumber(seq);
packet->SetTimestamp(timestamp); packet->SetTimestamp(timestamp);
#ifdef MS_RTC_LOGGER_RTP
packet->logger.sendRtpTimestamp = timestamp; packet->logger.sendRtpTimestamp = timestamp;
packet->logger.sendSeqNumber = seq; packet->logger.sendSeqNumber = seq;
#endif
if (isSyncPacket) if (isSyncPacket)
{ {
...@@ -1050,7 +1072,9 @@ namespace RTC ...@@ -1050,7 +1072,9 @@ namespace RTC
origSeq, origSeq,
origTimestamp); origTimestamp);
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::SEND_RTP_STREAM_DISCARDED); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::SEND_RTP_STREAM_DISCARDED);
#endif
} }
// Restore packet fields. // Restore packet fields.
......
...@@ -627,11 +627,15 @@ namespace RTC ...@@ -627,11 +627,15 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
#ifdef MS_RTC_LOGGER_RTP
packet->logger.consumerId = this->id; packet->logger.consumerId = this->id;
#endif
if (!IsActive()) if (!IsActive())
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
#endif
return; return;
} }
...@@ -643,7 +647,9 @@ namespace RTC ...@@ -643,7 +647,9 @@ namespace RTC
) )
// clang-format on // clang-format on
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::INVALID_TARGET_LAYER); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::INVALID_TARGET_LAYER);
#endif
return; return;
} }
...@@ -656,7 +662,9 @@ namespace RTC ...@@ -656,7 +662,9 @@ namespace RTC
{ {
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType); MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
#endif
return; return;
} }
...@@ -664,7 +672,9 @@ namespace RTC ...@@ -664,7 +672,9 @@ namespace RTC
// If we need to sync and this is not a key frame, ignore the packet. // If we need to sync and this is not a key frame, ignore the packet.
if (this->syncRequired && !packet->IsKeyFrame()) if (this->syncRequired && !packet->IsKeyFrame())
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
#endif
return; return;
} }
...@@ -696,7 +706,9 @@ namespace RTC ...@@ -696,7 +706,9 @@ namespace RTC
{ {
this->rtpSeqManager.Drop(packet->GetSequenceNumber()); this->rtpSeqManager.Drop(packet->GetSequenceNumber());
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC);
#endif
return; return;
} }
...@@ -725,8 +737,10 @@ namespace RTC ...@@ -725,8 +737,10 @@ namespace RTC
packet->SetSsrc(this->rtpParameters.encodings[0].ssrc); packet->SetSsrc(this->rtpParameters.encodings[0].ssrc);
packet->SetSequenceNumber(seq); packet->SetSequenceNumber(seq);
#ifdef MS_RTC_LOGGER_RTP
packet->logger.sendRtpTimestamp = packet->GetTimestamp(); packet->logger.sendRtpTimestamp = packet->GetTimestamp();
packet->logger.sendSeqNumber = seq; packet->logger.sendSeqNumber = seq;
#endif
if (marker) if (marker)
{ {
......
...@@ -1546,7 +1546,9 @@ namespace RTC ...@@ -1546,7 +1546,9 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
#ifdef MS_RTC_LOGGER_RTP
packet->logger.recvTransportId = this->id; packet->logger.recvTransportId = this->id;
#endif
// Apply the Transport RTP header extension ids so the RTP listener can use them. // Apply the Transport RTP header extension ids so the RTP listener can use them.
packet->SetMidExtensionId(this->recvRtpHeaderExtensionIds.mid); packet->SetMidExtensionId(this->recvRtpHeaderExtensionIds.mid);
...@@ -1568,7 +1570,9 @@ namespace RTC ...@@ -1568,7 +1570,9 @@ namespace RTC
if (!producer) if (!producer)
{ {
#ifdef MS_RTC_LOGGER_RTP
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::PRODUCER_NOT_FOUND); packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::PRODUCER_NOT_FOUND);
#endif
MS_WARN_TAG( MS_WARN_TAG(
rtp, rtp,
...@@ -2442,8 +2446,10 @@ namespace RTC ...@@ -2442,8 +2446,10 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
#ifdef MS_RTC_LOGGER_RTP
packet->logger.sendTransportId = this->id; packet->logger.sendTransportId = this->id;
packet->logger.Sent(); packet->logger.Sent();
#endif
// Update abs-send-time if present. // Update abs-send-time if present.
packet->UpdateAbsSendTime(DepLibUV::GetTimeMs()); packet->UpdateAbsSendTime(DepLibUV::GetTimeMs());
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论