提交 05cdd87a authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

worker: Use a new MS_DUMP() for Dump() methods

上级 5c5be6ec
...@@ -39,6 +39,10 @@ ...@@ -39,6 +39,10 @@
* Example: * Example:
* MS_DEBUG_DEV("Room closed [roomId:%" PRIu32 "]", roomId); * MS_DEBUG_DEV("Room closed [roomId:%" PRIu32 "]", roomId);
* *
* MS_DUMP(...)
*
* For Dump() methods.
*
* MS_ERROR(...) * MS_ERROR(...)
* *
* Logs an error. Must just be used for internal errors that should not * Logs an error. Must just be used for internal errors that should not
...@@ -265,6 +269,22 @@ public: ...@@ -265,6 +269,22 @@ public:
#define MS_WARN_DEV_STD(desc, ...) ; #define MS_WARN_DEV_STD(desc, ...) ;
#endif #endif
#define MS_DUMP(desc, ...) \
do \
{ \
int ms_logger_written = std::snprintf(Logger::buffer, MS_LOGGER_BUFFER_SIZE, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, ms_logger_written); \
} \
while (0)
#define MS_DUMP_STD(desc, ...) \
do \
{ \
std::fprintf(stdout, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \
std::fflush(stdout); \
} \
while (0)
#define MS_ERROR(desc, ...) \ #define MS_ERROR(desc, ...) \
do \ do \
{ \ { \
...@@ -311,6 +331,8 @@ public: ...@@ -311,6 +331,8 @@ public:
#define MS_DEBUG_DEV MS_DEBUG_DEV_STD #define MS_DEBUG_DEV MS_DEBUG_DEV_STD
#undef MS_WARN_DEV #undef MS_WARN_DEV
#define MS_WARN_DEV MS_WARN_DEV_STD #define MS_WARN_DEV MS_WARN_DEV_STD
#undef MS_DUMP
#define MS_DUMP MS_DUMP_STD
#undef MS_ERROR #undef MS_ERROR
#define MS_ERROR MS_ERROR_STD #define MS_ERROR MS_ERROR_STD
#endif #endif
......
...@@ -562,11 +562,13 @@ namespace RTC ...@@ -562,11 +562,13 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_TAG(dtls, "[role:%s, running:%s, handshake done:%s, connected:%s]", MS_DUMP("<DtlsTransport>");
MS_DUMP(" [role:%s, running:%s, handshake done:%s, connected:%s]",
(this->localRole == Role::SERVER ? "server" : (this->localRole == Role::CLIENT ? "client" : "none")), (this->localRole == Role::SERVER ? "server" : (this->localRole == Role::CLIENT ? "client" : "none")),
IsRunning() ? "yes" : "no", IsRunning() ? "yes" : "no",
this->handshakeDone ? "yes" : "no", this->handshakeDone ? "yes" : "no",
this->state == DtlsState::CONNECTED ? "yes" : "no"); this->state == DtlsState::CONNECTED ? "yes" : "no");
MS_DUMP("</DtlsTransport>");
} }
void DtlsTransport::Run(Role localRole) void DtlsTransport::Run(Role localRole)
......
...@@ -86,19 +86,15 @@ namespace RTC { namespace RTCP ...@@ -86,19 +86,15 @@ namespace RTC { namespace RTCP
void ByePacket::Dump() void ByePacket::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<ByePacket>"); MS_DUMP("<ByePacket>");
for (auto ssrc : this->ssrcs) for (auto ssrc : this->ssrcs)
{ {
MS_DEBUG_DEV(" ssrc : %" PRIu32, ssrc); MS_DUMP(" ssrc : %" PRIu32, ssrc);
} }
if (!this->reason.empty()) if (!this->reason.empty())
MS_DEBUG_DEV(" reason : %s", this->reason.c_str()); MS_DUMP(" reason : %s", this->reason.c_str());
MS_DEBUG_DEV("</ByePacket>"); MS_DUMP("</ByePacket>");
#endif
} }
}} }}
...@@ -73,11 +73,9 @@ namespace RTC { namespace RTCP ...@@ -73,11 +73,9 @@ namespace RTC { namespace RTCP
void CompoundPacket::Dump() void CompoundPacket::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<CompoundPacket>"); MS_DUMP("<CompoundPacket>");
if (this->senderReportPacket.GetCount()) if (this->senderReportPacket.GetCount())
{ {
...@@ -101,9 +99,7 @@ namespace RTC { namespace RTCP ...@@ -101,9 +99,7 @@ namespace RTC { namespace RTCP
if (this->sdesPacket.GetCount()) if (this->sdesPacket.GetCount())
this->sdesPacket.Dump(); this->sdesPacket.Dump();
MS_DEBUG_DEV("</CompoundPacket>"); MS_DUMP("</CompoundPacket>");
#endif
} }
void CompoundPacket::AddSenderReport(SenderReport* report) void CompoundPacket::AddSenderReport(SenderReport* report)
......
...@@ -83,9 +83,9 @@ namespace RTC { namespace RTCP ...@@ -83,9 +83,9 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV(" sender ssrc : %" PRIu32, (uint32_t)ntohl(this->header->s_ssrc)); MS_DUMP(" sender ssrc : %" PRIu32, (uint32_t)ntohl(this->header->s_ssrc));
MS_DEBUG_DEV(" media ssrc : %" PRIu32, (uint32_t)ntohl(this->header->m_ssrc)); MS_DUMP(" media ssrc : %" PRIu32, (uint32_t)ntohl(this->header->m_ssrc));
MS_DEBUG_DEV(" size : %zu", this->GetSize()); MS_DUMP(" size : %zu", this->GetSize());
} }
/* Specialization for Ps class. */ /* Specialization for Ps class. */
......
...@@ -69,19 +69,15 @@ namespace RTC { namespace RTCP ...@@ -69,19 +69,15 @@ namespace RTC { namespace RTCP
template<typename Item> template<typename Item>
void FeedbackPsItemPacket<Item>::Dump() void FeedbackPsItemPacket<Item>::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<%s>", FeedbackPsPacket::MessageType2String(Item::MessageType).c_str()); MS_DUMP("<%s>", FeedbackPsPacket::MessageType2String(Item::MessageType).c_str());
FeedbackPsPacket::Dump(); FeedbackPsPacket::Dump();
for (auto item : this->items) for (auto item : this->items)
{ {
item->Dump(); item->Dump();
} }
MS_DEBUG_DEV("</%s>", FeedbackPsPacket::MessageType2String(Item::MessageType).c_str()); MS_DUMP("</%s>", FeedbackPsPacket::MessageType2String(Item::MessageType).c_str());
#endif
} }
// explicit instantiation to have all FeedbackRtpPacket definitions in this file. // explicit instantiation to have all FeedbackRtpPacket definitions in this file.
......
...@@ -40,14 +40,10 @@ namespace RTC { namespace RTCP ...@@ -40,14 +40,10 @@ namespace RTC { namespace RTCP
void FeedbackPsAfbPacket::Dump() void FeedbackPsAfbPacket::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<FeedbackPsAfbPacket>"); MS_DUMP("<FeedbackPsAfbPacket>");
FeedbackPsPacket::Dump(); FeedbackPsPacket::Dump();
MS_DEBUG_DEV("</FeedbackPsAfbPacket>"); MS_DUMP("</FeedbackPsAfbPacket>");
#endif
} }
}} }}
...@@ -56,9 +56,9 @@ namespace RTC { namespace RTCP ...@@ -56,9 +56,9 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<FirItem>"); MS_DUMP("<FirItem>");
MS_DEBUG_DEV(" ssrc : %" PRIu32, this->GetSsrc()); MS_DUMP(" ssrc : %" PRIu32, this->GetSsrc());
MS_DEBUG_DEV(" sequence number : %" PRIu8, this->GetSequenceNumber()); MS_DUMP(" sequence number : %" PRIu8, this->GetSequenceNumber());
MS_DEBUG_DEV("\t\t</FirItem>"); MS_DUMP("</FirItem>");
} }
}} }}
...@@ -50,8 +50,8 @@ namespace RTC { namespace RTCP ...@@ -50,8 +50,8 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<PsLeiItem>"); MS_DUMP("<PsLeiItem>");
MS_DEBUG_DEV(" ssrc : %" PRIu32, this->GetSsrc()); MS_DUMP(" ssrc : %" PRIu32, this->GetSsrc());
MS_DEBUG_DEV("</PsLeiItem>"); MS_DUMP("</PsLeiItem>");
} }
}} }}
...@@ -27,14 +27,10 @@ namespace RTC { namespace RTCP ...@@ -27,14 +27,10 @@ namespace RTC { namespace RTCP
void FeedbackPsPliPacket::Dump() void FeedbackPsPliPacket::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<FeedbackPsPliPacket>"); MS_DUMP("<FeedbackPsPliPacket>");
FeedbackPsPacket::Dump(); FeedbackPsPacket::Dump();
MS_DEBUG_DEV("</FeedbackPsPliPacket>"); MS_DUMP("</FeedbackPsPliPacket>");
#endif
} }
}} }}
...@@ -95,10 +95,10 @@ namespace RTC { namespace RTCP ...@@ -95,10 +95,10 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<RpsiItem>"); MS_DUMP("<RpsiItem>");
MS_DEBUG_DEV(" padding bits : %" PRIu8, this->header->padding_bits); MS_DUMP(" padding bits : %" PRIu8, this->header->padding_bits);
MS_DEBUG_DEV(" payload type : %" PRIu8, this->GetPayloadType()); MS_DUMP(" payload type : %" PRIu8, this->GetPayloadType());
MS_DEBUG_DEV(" length : %zu", this->GetLength()); MS_DUMP(" length : %zu", this->GetLength());
MS_DEBUG_DEV("</RpsiItem>"); MS_DUMP("</RpsiItem>");
} }
}} }}
...@@ -56,11 +56,11 @@ namespace RTC { namespace RTCP ...@@ -56,11 +56,11 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<SliItem>"); MS_DUMP("<SliItem>");
MS_DEBUG_DEV(" first : %" PRIu16, this->first); MS_DUMP(" first : %" PRIu16, this->first);
MS_DEBUG_DEV(" number : %" PRIu16, this->number); MS_DUMP(" number : %" PRIu16, this->number);
MS_DEBUG_DEV(" picture id : %" PRIu8, this->pictureId); MS_DUMP(" picture id : %" PRIu8, this->pictureId);
MS_DEBUG_DEV("</SliItem>"); MS_DUMP("</SliItem>");
} }
}} }}
...@@ -58,11 +58,11 @@ namespace RTC { namespace RTCP ...@@ -58,11 +58,11 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<TstItem>"); MS_DUMP("<TstItem>");
MS_DEBUG_DEV(" ssrc : %" PRIu32, this->GetSsrc()); MS_DUMP(" ssrc : %" PRIu32, this->GetSsrc());
MS_DEBUG_DEV(" sequence number : %" PRIu32, this->GetSequenceNumber()); MS_DUMP(" sequence number : %" PRIu32, this->GetSequenceNumber());
MS_DEBUG_DEV(" index : %" PRIu32, this->GetIndex()); MS_DUMP(" index : %" PRIu32, this->GetIndex());
MS_DEBUG_DEV("</TstItem>"); MS_DUMP("</TstItem>");
} }
/* Specialization for Tstr class. */ /* Specialization for Tstr class. */
......
...@@ -66,11 +66,11 @@ namespace RTC { namespace RTCP ...@@ -66,11 +66,11 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<VbcmItem>"); MS_DUMP("<VbcmItem>");
MS_DEBUG_DEV(" ssrc : %" PRIu32, this->GetSsrc()); MS_DUMP(" ssrc : %" PRIu32, this->GetSsrc());
MS_DEBUG_DEV(" sequence number : %" PRIu8, this->GetSequenceNumber()); MS_DUMP(" sequence number : %" PRIu8, this->GetSequenceNumber());
MS_DEBUG_DEV(" payload type : %" PRIu8, this->GetPayloadType()); MS_DUMP(" payload type : %" PRIu8, this->GetPayloadType());
MS_DEBUG_DEV(" length : %" PRIu16, this->GetLength()); MS_DUMP(" length : %" PRIu16, this->GetLength());
MS_DEBUG_DEV("</Vbcm Item>"); MS_DUMP("</VbcmItem>");
} }
}} }}
...@@ -67,19 +67,15 @@ namespace RTC { namespace RTCP ...@@ -67,19 +67,15 @@ namespace RTC { namespace RTCP
template<typename Item> template<typename Item>
void FeedbackRtpItemPacket<Item>::Dump() void FeedbackRtpItemPacket<Item>::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<%s>", FeedbackRtpPacket::MessageType2String(Item::MessageType).c_str()); MS_DUMP("<%s>", FeedbackRtpPacket::MessageType2String(Item::MessageType).c_str());
FeedbackRtpPacket::Dump(); FeedbackRtpPacket::Dump();
for (auto item : this->items) for (auto item : this->items)
{ {
item->Dump(); item->Dump();
} }
MS_DEBUG_DEV("</%s>", FeedbackRtpPacket::MessageType2String(Item::MessageType).c_str()); MS_DUMP("</%s>", FeedbackRtpPacket::MessageType2String(Item::MessageType).c_str());
#endif
} }
// Explicit instantiation to have all FeedbackRtpPacket definitions in this file. // Explicit instantiation to have all FeedbackRtpPacket definitions in this file.
......
...@@ -40,14 +40,14 @@ namespace RTC { namespace RTCP ...@@ -40,14 +40,14 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<EcnItem>"); MS_DUMP("<EcnItem>");
MS_DEBUG_DEV(" sequence number : %" PRIu32, this->GetSequenceNumber()); MS_DUMP(" sequence number : %" PRIu32, this->GetSequenceNumber());
MS_DEBUG_DEV(" ect0 counter : %" PRIu32, this->GetEct0Counter()); MS_DUMP(" ect0 counter : %" PRIu32, this->GetEct0Counter());
MS_DEBUG_DEV(" ect1 counter : %" PRIu32, this->GetEct1Counter()); MS_DUMP(" ect1 counter : %" PRIu32, this->GetEct1Counter());
MS_DEBUG_DEV(" ecn ce counter : %" PRIu16, this->GetEcnCeCounter()); MS_DUMP(" ecn ce counter : %" PRIu16, this->GetEcnCeCounter());
MS_DEBUG_DEV(" not ect counter : %" PRIu16, this->GetNotEctcounter()); MS_DUMP(" not ect counter : %" PRIu16, this->GetNotEctCounter());
MS_DEBUG_DEV(" lost packets : %" PRIu16, this->GetLostPackets()); MS_DUMP(" lost packets : %" PRIu16, this->GetLostPackets());
MS_DEBUG_DEV(" duplicated packets : %" PRIu16, this->GetDuplicatedPackets()); MS_DUMP(" duplicated packets : %" PRIu16, this->GetDuplicatedPackets());
MS_DEBUG_DEV("</EcnItem>"); MS_DUMP("</EcnItem>");
} }
}} }}
...@@ -50,9 +50,9 @@ namespace RTC { namespace RTCP ...@@ -50,9 +50,9 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<NackItem>"); MS_DUMP("<NackItem>");
MS_DEBUG_DEV(" pid : %" PRIu16, this->GetPacketId()); MS_DUMP(" pid : %" PRIu16, this->GetPacketId());
MS_DEBUG_DEV(" bpl : %" PRIu16, this->GetLostPacketBitmask()); MS_DUMP(" bpl : %" PRIu16, this->GetLostPacketBitmask());
MS_DEBUG_DEV("</NackItem>"); MS_DUMP("</NackItem>");
} }
}} }}
...@@ -26,14 +26,10 @@ namespace RTC { namespace RTCP ...@@ -26,14 +26,10 @@ namespace RTC { namespace RTCP
void FeedbackRtpSrReqPacket::Dump() void FeedbackRtpSrReqPacket::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<FeedbackRtpSrReqPacket>"); MS_DUMP("<FeedbackRtpSrReqPacket>");
FeedbackRtpPacket::Dump(); FeedbackRtpPacket::Dump();
MS_DEBUG_DEV("</FeedbackRtpSrReqPacket>"); MS_DUMP("</FeedbackRtpSrReqPacket>");
#endif
} }
}} }}
...@@ -50,9 +50,9 @@ namespace RTC { namespace RTCP ...@@ -50,9 +50,9 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<TlleiItem>"); MS_DUMP("<TlleiItem>");
MS_DEBUG_DEV(" pid: %" PRIu16, this->GetPacketId()); MS_DUMP(" pid: %" PRIu16, this->GetPacketId());
MS_DEBUG_DEV(" bpl: %" PRIu16, this->GetLostPacketBitmask()); MS_DUMP(" bpl: %" PRIu16, this->GetLostPacketBitmask());
MS_DEBUG_DEV("</TlleiItem>"); MS_DUMP("</TlleiItem>");
} }
}} }}
...@@ -81,11 +81,11 @@ namespace RTC { namespace RTCP ...@@ -81,11 +81,11 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<TmmbItem>"); MS_DUMP("<TmmbItem>");
MS_DEBUG_DEV(" ssrc : %" PRIu32, this->GetSsrc()); MS_DUMP(" ssrc : %" PRIu32, this->GetSsrc());
MS_DEBUG_DEV(" bitrate : %" PRIu64, this->GetBitrate()); MS_DUMP(" bitrate : %" PRIu64, this->GetBitrate());
MS_DEBUG_DEV(" overhead : %" PRIu16, this->GetOverhead()); MS_DUMP(" overhead : %" PRIu16, this->GetOverhead());
MS_DEBUG_DEV("</TmmbItem>"); MS_DUMP("</TmmbItem>");
} }
/* Specialization for Tmmbr class. */ /* Specialization for Tmmbr class. */
......
...@@ -134,10 +134,6 @@ namespace RTC { namespace RTCP ...@@ -134,10 +134,6 @@ namespace RTC { namespace RTCP
return first; return first;
} }
#ifdef MS_LOG_DEV
// current->Dump();
#endif
data += packet_len; data += packet_len;
len -= packet_len; len -= packet_len;
......
#define MS_CLASS "RTC::RTCP::ReceiverReport" #define MS_CLASS "RTC::RTCP::ReceiverReport"
// #define MS_LOG_DEV #define MS_LOG_DEV
#include "RTC/RTCP/ReceiverReport.hpp" #include "RTC/RTCP/ReceiverReport.hpp"
#include "Utils.hpp" #include "Utils.hpp"
...@@ -34,15 +34,15 @@ namespace RTC { namespace RTCP ...@@ -34,15 +34,15 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<ReceiverReport>"); MS_DUMP("<ReceiverReport>");
MS_DEBUG_DEV(" ssrc : %" PRIu32, this->GetSsrc()); MS_DUMP(" ssrc : %" PRIu32, this->GetSsrc());
MS_DEBUG_DEV(" fraction lost : %" PRIu32, this->GetFractionLost()); MS_DUMP(" fraction lost : %" PRIu32, this->GetFractionLost());
MS_DEBUG_DEV(" total lost : %" PRIu32, this->GetTotalLost()); MS_DUMP(" total lost : %" PRIu32, this->GetTotalLost());
MS_DEBUG_DEV(" last seq : %" PRIu32, this->GetLastSeq()); MS_DUMP(" last seq : %" PRIu32, this->GetLastSeq());
MS_DEBUG_DEV(" jitter : %" PRIu32, this->GetJitter()); MS_DUMP(" jitter : %" PRIu32, this->GetJitter());
MS_DEBUG_DEV(" lsr : %" PRIu32, this->GetLastSenderReport()); MS_DUMP(" lsr : %" PRIu32, this->GetLastSenderReport());
MS_DEBUG_DEV(" dlsr : %" PRIu32, this->GetDelaySinceLastSenderReport()); MS_DUMP(" dlsr : %" PRIu32, this->GetDelaySinceLastSenderReport());
MS_DEBUG_DEV("</ReceiverReport>"); MS_DUMP("</ReceiverReport>");
} }
size_t ReceiverReport::Serialize(uint8_t* buffer) size_t ReceiverReport::Serialize(uint8_t* buffer)
...@@ -119,16 +119,12 @@ namespace RTC { namespace RTCP ...@@ -119,16 +119,12 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
#ifdef MS_LOG_DEV MS_DUMP("<ReceiverReportPacket>");
MS_DUMP(" ssrc: %" PRIu32, (uint32_t)ntohl(this->ssrc));
MS_DEBUG_DEV("<ReceiverReportPacket>");
MS_DEBUG_DEV(" ssrc: %" PRIu32, (uint32_t)ntohl(this->ssrc));
for (auto report : this->reports) for (auto report : this->reports)
{ {
report->Dump(); report->Dump();
} }
MS_DEBUG_DEV("</ReceiverReportPacket>"); MS_DUMP("</ReceiverReportPacket>");
#endif
} }
}} }}
#define MS_CLASS "RTC::RTCP::Sdes" #define MS_CLASS "RTC::RTCP::Sdes"
// #define MS_LOG_DEV #define MS_LOG_DEV
#include "RTC/RTCP/Sdes.hpp" #include "RTC/RTCP/Sdes.hpp"
#include "Utils.hpp" #include "Utils.hpp"
...@@ -76,11 +76,11 @@ namespace RTC { namespace RTCP ...@@ -76,11 +76,11 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<SdesItem>"); MS_DUMP("<SdesItem>");
MS_DEBUG_DEV(" type : %s", Type2String(this->GetType()).c_str()); MS_DUMP(" type : %s", Type2String(this->GetType()).c_str());
MS_DEBUG_DEV(" length : %" PRIu8, this->header->length); MS_DUMP(" length : %" PRIu8, this->header->length);
MS_DEBUG_DEV(" value : %.*s", this->header->length, this->header->value); MS_DUMP(" value : %.*s", this->header->length, this->header->value);
MS_DEBUG_DEV("</SdesItem>"); MS_DUMP("</SdesItem>");
} }
size_t SdesItem::Serialize(uint8_t* buffer) size_t SdesItem::Serialize(uint8_t* buffer)
...@@ -161,19 +161,15 @@ namespace RTC { namespace RTCP ...@@ -161,19 +161,15 @@ namespace RTC { namespace RTCP
void SdesChunk::Dump() void SdesChunk::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<SdesChunk>"); MS_DUMP("<SdesChunk>");
MS_DEBUG_DEV(" ssrc : %" PRIu32, (uint32_t)ntohl(this->ssrc)); MS_DUMP(" ssrc : %" PRIu32, (uint32_t)ntohl(this->ssrc));
for (auto item : this->items) for (auto item : this->items)
{ {
item->Dump(); item->Dump();
} }
MS_DEBUG_DEV("</SdesChunk>"); MS_DUMP("</SdesChunk>");
#endif
} }
/* Class methods. */ /* Class methods. */
...@@ -223,17 +219,13 @@ namespace RTC { namespace RTCP ...@@ -223,17 +219,13 @@ namespace RTC { namespace RTCP
void SdesPacket::Dump() void SdesPacket::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<SdesPacket>"); MS_DUMP("<SdesPacket>");
for (auto chunk : this->chunks) for (auto chunk : this->chunks)
{ {
chunk->Dump(); chunk->Dump();
} }
MS_DEBUG_DEV("</SdesPacket>"); MS_DUMP("</SdesPacket>");
#endif
} }
}} }}
#define MS_CLASS "RTC::RTCP::SenderReport" #define MS_CLASS "RTC::RTCP::SenderReport"
// #define MS_LOG_DEV #define MS_LOG_DEV
#include "RTC/RTCP/SenderReport.hpp" #include "RTC/RTCP/SenderReport.hpp"
#include "Logger.hpp" #include "Logger.hpp"
...@@ -33,14 +33,14 @@ namespace RTC { namespace RTCP ...@@ -33,14 +33,14 @@ namespace RTC { namespace RTCP
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<SenderReport>"); MS_DUMP("<SenderReport>");
MS_DEBUG_DEV(" ssrc : %" PRIu32, this->GetSsrc()); MS_DUMP(" ssrc : %" PRIu32, this->GetSsrc());
MS_DEBUG_DEV(" ntp sec : %" PRIu32, this->GetNtpSec()); MS_DUMP(" ntp sec : %" PRIu32, this->GetNtpSec());
MS_DEBUG_DEV(" ntp frac : %" PRIu32, this->GetNtpFrac()); MS_DUMP(" ntp frac : %" PRIu32, this->GetNtpFrac());
MS_DEBUG_DEV(" rtp ts : %" PRIu32, this->GetRtpTs()); MS_DUMP(" rtp ts : %" PRIu32, this->GetRtpTs());
MS_DEBUG_DEV(" packet count : %" PRIu32, this->GetPacketCount()); MS_DUMP(" packet count : %" PRIu32, this->GetPacketCount());
MS_DEBUG_DEV(" octet count : %" PRIu32, this->GetOctetCount()); MS_DUMP(" octet count : %" PRIu32, this->GetOctetCount());
MS_DEBUG_DEV("</SenderReport>"); MS_DUMP("</SenderReport>");
} }
size_t SenderReport::Serialize(uint8_t* buffer) size_t SenderReport::Serialize(uint8_t* buffer)
...@@ -92,17 +92,13 @@ namespace RTC { namespace RTCP ...@@ -92,17 +92,13 @@ namespace RTC { namespace RTCP
void SenderReportPacket::Dump() void SenderReportPacket::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<SenderReportPacket>"); MS_DUMP("<SenderReportPacket>");
for (auto report : this->reports) for (auto report : this->reports)
{ {
report->Dump(); report->Dump();
} }
MS_DEBUG_DEV("</SenderReportPacket>"); MS_DUMP("</SenderReportPacket>");
#endif
} }
}} }}
...@@ -144,28 +144,24 @@ namespace RTC ...@@ -144,28 +144,24 @@ namespace RTC
void RtpPacket::Dump() void RtpPacket::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<RtpPacket>"); MS_DUMP("<RtpPacket>");
MS_DEBUG_DEV(" padding : %s", this->header->padding ? "true" : "false"); MS_DUMP(" padding : %s", this->header->padding ? "true" : "false");
MS_DEBUG_DEV(" extension header : %s", HasExtensionHeader() ? "true" : "false"); MS_DUMP(" extension header : %s", HasExtensionHeader() ? "true" : "false");
if (HasExtensionHeader()) if (HasExtensionHeader())
{ {
MS_DEBUG_DEV(" id : %" PRIu16, GetExtensionHeaderId()); MS_DUMP(" id : %" PRIu16, GetExtensionHeaderId());
MS_DEBUG_DEV(" length : %zu bytes", GetExtensionHeaderLength()); MS_DUMP(" length : %zu bytes", GetExtensionHeaderLength());
} }
MS_DEBUG_DEV(" csrc count : %" PRIu8, this->header->csrc_count); MS_DUMP(" csrc count : %" PRIu8, this->header->csrc_count);
MS_DEBUG_DEV(" marker : %s", HasMarker() ? "true" : "false"); MS_DUMP(" marker : %s", HasMarker() ? "true" : "false");
MS_DEBUG_DEV(" payload type : %" PRIu8, GetPayloadType()); MS_DUMP(" payload type : %" PRIu8, GetPayloadType());
MS_DEBUG_DEV(" sequence number : %" PRIu16, GetSequenceNumber()); MS_DUMP(" sequence number : %" PRIu16, GetSequenceNumber());
MS_DEBUG_DEV(" timestamp : %" PRIu32, GetTimestamp()); MS_DUMP(" timestamp : %" PRIu32, GetTimestamp());
MS_DEBUG_DEV(" ssrc : %" PRIu32, GetSsrc()); MS_DUMP(" ssrc : %" PRIu32, GetSsrc());
MS_DEBUG_DEV(" payload size : %zu bytes", GetPayloadLength()); MS_DUMP(" payload size : %zu bytes", GetPayloadLength());
MS_DEBUG_DEV("</RtpPacket>"); MS_DUMP("</RtpPacket>");
#endif
} }
void RtpPacket::ParseExtensionElements() void RtpPacket::ParseExtensionElements()
......
...@@ -299,18 +299,15 @@ namespace RTC ...@@ -299,18 +299,15 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG_TAG(rtp, "<RtpStreamSend>"); MS_DUMP("<RtpStreamSend>");
MS_DUMP(" [buffer.size:%zu, storage.size:%zu]", this->buffer.size(), this->storage.size());
MS_DEBUG_TAG(rtp, " [buffer.size:%zu, storage.size:%zu]", this->buffer.size(), this->storage.size());
for (auto& buffer_item : this->buffer) for (auto& buffer_item : this->buffer)
{ {
auto packet = buffer_item.packet; auto packet = buffer_item.packet;
MS_DEBUG_TAG(rtp, " packet [seq:%" PRIu16 ", seq32:%" PRIu32 "]", packet->GetSequenceNumber(), buffer_item.seq32); MS_DUMP(" packet [seq:%" PRIu16 ", seq32:%" PRIu32 "]", packet->GetSequenceNumber(), buffer_item.seq32);
} }
MS_DUMP("</RtpStreamSend>");
MS_DEBUG_TAG(rtp, "</RtpStreamSend>");
} }
RTC::RTCP::SenderReport* RtpStreamSend::GetRtcpSenderReport(uint64_t now) RTC::RTCP::SenderReport* RtpStreamSend::GetRtcpSenderReport(uint64_t now)
......
...@@ -242,11 +242,9 @@ namespace RTC ...@@ -242,11 +242,9 @@ namespace RTC
void StunMessage::Dump() void StunMessage::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
MS_DEBUG_DEV("<StunMessage>"); MS_DUMP("<StunMessage>");
std::string klass; std::string klass;
switch (this->klass) switch (this->klass)
...@@ -257,30 +255,34 @@ namespace RTC ...@@ -257,30 +255,34 @@ namespace RTC
case Class::ErrorResponse : klass = "ErrorResponse"; break; case Class::ErrorResponse : klass = "ErrorResponse"; break;
} }
if (this->method == Method::Binding) if (this->method == Method::Binding)
MS_DEBUG_DEV(" Binding %s", klass.c_str()); {
MS_DUMP(" Binding %s", klass.c_str());
}
else else
{
// This prints the unknown method number. Example: TURN Allocate => 0x003. // This prints the unknown method number. Example: TURN Allocate => 0x003.
MS_DEBUG_DEV(" %s with unknown method %#.3x", klass.c_str(), (uint16_t)this->method); MS_DUMP(" %s with unknown method %#.3x", klass.c_str(), (uint16_t)this->method);
MS_DEBUG_DEV(" size: %zu bytes", this->size); }
MS_DUMP(" size: %zu bytes", this->size);
char transaction_id[25]; char transaction_id[25];
for (int i=0; i<12; ++i) for (int i=0; i<12; ++i)
{ {
// NOTE: n must be 3 because snprintf adds a \0 after printed chars. // NOTE: n must be 3 because snprintf adds a \0 after printed chars.
std::snprintf(transaction_id+(i*2), 3, "%.2x", this->transactionId[i]); std::snprintf(transaction_id+(i*2), 3, "%.2x", this->transactionId[i]);
} }
MS_DEBUG_DEV(" transactionId: %s", transaction_id); MS_DUMP(" transactionId: %s", transaction_id);
if (this->errorCode) if (this->errorCode)
MS_DEBUG_DEV(" errorCode: %" PRIu16, this->errorCode); MS_DUMP(" errorCode: %" PRIu16, this->errorCode);
if (!this->username.empty()) if (!this->username.empty())
MS_DEBUG_DEV(" username: %s", this->username.c_str()); MS_DUMP(" username: %s", this->username.c_str());
if (this->priority) if (this->priority)
MS_DEBUG_DEV(" priority: %" PRIu32, this->priority); MS_DUMP(" priority: %" PRIu32, this->priority);
if (this->iceControlling) if (this->iceControlling)
MS_DEBUG_DEV(" iceControlling: %" PRIu64, this->iceControlling); MS_DUMP(" iceControlling: %" PRIu64, this->iceControlling);
if (this->iceControlled) if (this->iceControlled)
MS_DEBUG_DEV(" iceControlled: %" PRIu64, this->iceControlled); MS_DUMP(" iceControlled: %" PRIu64, this->iceControlled);
if (this->hasUseCandidate) if (this->hasUseCandidate)
MS_DEBUG_DEV(" useCandidate"); MS_DUMP(" useCandidate");
if (this->xorMappedAddress) if (this->xorMappedAddress)
{ {
int family; int family;
...@@ -288,7 +290,7 @@ namespace RTC ...@@ -288,7 +290,7 @@ namespace RTC
std::string ip; std::string ip;
Utils::IP::GetAddressInfo(this->xorMappedAddress, &family, ip, &port); Utils::IP::GetAddressInfo(this->xorMappedAddress, &family, ip, &port);
MS_DEBUG_DEV(" xorMappedAddress: %s : %" PRIu16, ip.c_str(), port); MS_DUMP(" xorMappedAddress: %s : %" PRIu16, ip.c_str(), port);
} }
if (this->messageIntegrity) if (this->messageIntegrity)
{ {
...@@ -298,14 +300,12 @@ namespace RTC ...@@ -298,14 +300,12 @@ namespace RTC
std::snprintf(message_integrity+(i*2), 3, "%.2x", this->messageIntegrity[i]); std::snprintf(message_integrity+(i*2), 3, "%.2x", this->messageIntegrity[i]);
} }
MS_DEBUG_DEV(" messageIntegrity: %s", message_integrity); MS_DUMP(" messageIntegrity: %s", message_integrity);
} }
if (this->hasFingerprint) if (this->hasFingerprint)
MS_DEBUG_DEV(" fingerprint"); MS_DUMP(" fingerprint");
MS_DEBUG_DEV("</StunMessage>");
#endif MS_DUMP("</StunMessage>");
} }
StunMessage::Authentication StunMessage::CheckAuthentication(const std::string &local_username, const std::string &local_password) StunMessage::Authentication StunMessage::CheckAuthentication(const std::string &local_username, const std::string &local_password)
......
...@@ -756,9 +756,6 @@ namespace RTC ...@@ -756,9 +756,6 @@ namespace RTC
} }
MS_DEBUG_DEV("valid RTP packet received [ssrc:%" PRIu32 ", payloadType:%" PRIu8 ", rtpReceiver:%" PRIu32 "]", packet->GetSsrc(), packet->GetPayloadType(), rtpReceiver->rtpReceiverId); MS_DEBUG_DEV("valid RTP packet received [ssrc:%" PRIu32 ", payloadType:%" PRIu8 ", rtpReceiver:%" PRIu32 "]", packet->GetSsrc(), packet->GetPayloadType(), rtpReceiver->rtpReceiverId);
#ifdef MS_LOG_DEV
// packet->Dump();
#endif
// Trick for clients performing aggressive ICE regardless we are ICE-Lite. // Trick for clients performing aggressive ICE regardless we are ICE-Lite.
this->iceServer->ForceSelectedTuple(tuple); this->iceServer->ForceSelectedTuple(tuple);
......
...@@ -44,8 +44,6 @@ namespace RTC ...@@ -44,8 +44,6 @@ namespace RTC
void TransportTuple::Dump() void TransportTuple::Dump()
{ {
#ifdef MS_LOG_DEV
MS_TRACE(); MS_TRACE();
switch (this->protocol) switch (this->protocol)
...@@ -58,21 +56,23 @@ namespace RTC ...@@ -58,21 +56,23 @@ namespace RTC
Utils::IP::GetAddressInfo(GetRemoteAddress(), &remote_family, remote_ip, &remote_port); Utils::IP::GetAddressInfo(GetRemoteAddress(), &remote_family, remote_ip, &remote_port);
MS_DEBUG_DEV("[UDP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]", MS_DUMP("<TransportTuple>");
MS_DUMP(" [UDP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]",
this->udpSocket->GetLocalIP().c_str(), this->udpSocket->GetLocalPort(), this->udpSocket->GetLocalIP().c_str(), this->udpSocket->GetLocalPort(),
remote_ip.c_str(), remote_port); remote_ip.c_str(), remote_port);
MS_DUMP("</TransportTuple>");
break; break;
} }
case Protocol::TCP: case Protocol::TCP:
{ {
MS_DEBUG_DEV("[TCP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]", MS_DUMP("<TransportTuple>");
MS_DUMP(" [TCP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]",
this->tcpConnection->GetLocalIP().c_str(), this->tcpConnection->GetLocalPort(), this->tcpConnection->GetLocalIP().c_str(), this->tcpConnection->GetLocalPort(),
this->tcpConnection->GetPeerIP().c_str(), this->tcpConnection->GetPeerPort()); this->tcpConnection->GetPeerIP().c_str(), this->tcpConnection->GetPeerPort());
MS_DUMP("</TransportTuple>");
break; break;
} }
} }
#endif
} }
} }
...@@ -133,10 +133,12 @@ void TcpConnection::Close() ...@@ -133,10 +133,12 @@ void TcpConnection::Close()
void TcpConnection::Dump() void TcpConnection::Dump()
{ {
MS_DEBUG_DEV("[Tcp, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 ", status:%s]", MS_DUMP("<TcpConnection>");
MS_DUMP(" [TCP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 ", status:%s]",
this->localIP.c_str(), (uint16_t)this->localPort, this->localIP.c_str(), (uint16_t)this->localPort,
this->peerIP.c_str(), (uint16_t)this->peerPort, this->peerIP.c_str(), (uint16_t)this->peerPort,
(!this->isClosing) ? "open" : "closed"); (!this->isClosing) ? "open" : "closed");
MS_DUMP("</TcpConnection>");
} }
void TcpConnection::Start() void TcpConnection::Start()
......
...@@ -154,10 +154,12 @@ void TcpServer::Close() ...@@ -154,10 +154,12 @@ void TcpServer::Close()
void TcpServer::Dump() void TcpServer::Dump()
{ {
MS_DEBUG_DEV("[TCP, local:%s :%" PRIu16 ", status:%s, connections:%zu]", MS_DUMP("<TcpServer>");
MS_DUMP(" [TCP, local:%s :%" PRIu16 ", status:%s, connections:%zu]",
this->localIP.c_str(), (uint16_t)this->localPort, this->localIP.c_str(), (uint16_t)this->localPort,
(!this->isClosing) ? "open" : "closed", (!this->isClosing) ? "open" : "closed",
this->connections.size()); this->connections.size());
MS_DUMP("</TcpServer>");
} }
const struct sockaddr* TcpServer::GetLocalAddress() const struct sockaddr* TcpServer::GetLocalAddress()
...@@ -292,7 +294,6 @@ void TcpServer::onTcpConnectionClosed(TcpConnection* connection, bool is_closed_ ...@@ -292,7 +294,6 @@ void TcpServer::onTcpConnectionClosed(TcpConnection* connection, bool is_closed_
bool wasClosing = this->isClosing; bool wasClosing = this->isClosing;
MS_DEBUG_DEV("TCP connection closed"); MS_DEBUG_DEV("TCP connection closed");
connection->Dump();
// Remove the TcpConnection from the set. // Remove the TcpConnection from the set.
this->connections.erase(connection); this->connections.erase(connection);
......
...@@ -172,9 +172,11 @@ void UdpSocket::Close() ...@@ -172,9 +172,11 @@ void UdpSocket::Close()
void UdpSocket::Dump() void UdpSocket::Dump()
{ {
MS_DEBUG_DEV("[UDP, local:%s :%" PRIu16 ", status:%s]", MS_DUMP("<UdpSocket>");
MS_DUMP(" [UDP, local:%s :%" PRIu16 ", status:%s]",
this->localIP.c_str(), (uint16_t)this->localPort, this->localIP.c_str(), (uint16_t)this->localPort,
(!this->isClosing) ? "open" : "closed"); (!this->isClosing) ? "open" : "closed");
MS_DUMP("</UdpSocket>");
} }
void UdpSocket::Send(const uint8_t* data, size_t len, const struct sockaddr* addr) void UdpSocket::Send(const uint8_t* data, size_t len, const struct sockaddr* addr)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论