-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathRtcLogger.cpp
More file actions
100 lines (86 loc) · 3.53 KB
/
RtcLogger.cpp
File metadata and controls
100 lines (86 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#define MS_CLASS "RTC::RtcLogger"
// #define MS_LOG_DEV_LEVEL 3
#include "RTC/RtcLogger.hpp"
#include "Logger.hpp"
namespace RTC
{
namespace RtcLogger
{
// clang-format off
absl::flat_hash_map<RtpPacket::DiscardReason, std::string> RtpPacket::discardReason2String = {
{ RtpPacket::DiscardReason::NONE, "None" },
{ RtpPacket::DiscardReason::PRODUCER_NOT_FOUND, "ProducerNotFound" },
{ RtpPacket::DiscardReason::RECV_RTP_STREAM_NOT_FOUND, "RecvRtpStreamNotFound" },
{ RtpPacket::DiscardReason::RECV_RTP_STREAM_DISCARDED, "RecvRtpStreamDiscarded" },
{ RtpPacket::DiscardReason::CONSUMER_INACTIVE, "ConsumerInactive" },
{ RtpPacket::DiscardReason::INVALID_TARGET_LAYER, "InvalidTargetLayer" },
{ RtpPacket::DiscardReason::UNSUPPORTED_PAYLOAD_TYPE, "UnsupportedPayloadType" },
{ RtpPacket::DiscardReason::NOT_A_KEYFRAME, "NotAKeyframe" },
{ RtpPacket::DiscardReason::EMPTY_PAYLOAD, "EmptyPayload" },
{ RtpPacket::DiscardReason::SPATIAL_LAYER_MISMATCH, "SpatialLayerMismatch" },
{ RtpPacket::DiscardReason::PACKET_PREVIOUS_TO_SPATIAL_LAYER_SWITCH, "PacketPreviousToSpatialLayerSwitch" },
{ RtpPacket::DiscardReason::DROPPED_BY_CODEC, "DroppedByCodec" },
{ RtpPacket::DiscardReason::TOO_HIGH_TIMESTAMP_EXTRA_NEEDED, "TooHighTimestampExtraNeeded"},
{ RtpPacket::DiscardReason::SEND_RTP_STREAM_DISCARDED, "SendRtpStreamDiscarded"}
};
// clang-format on
void RtpPacket::Sent()
{
MS_TRACE();
this->discarded = false;
Log();
Clear();
}
void RtpPacket::Discarded(DiscardReason discardReason)
{
MS_TRACE();
this->discarded = true;
this->discardReason = discardReason;
Log();
Clear();
}
void RtpPacket::Log() const
{
MS_TRACE();
std::cout << "{";
std::cout << "\"timestamp\": " << this->timestamp;
if (!this->recvTransportId.empty())
{
std::cout << R"(, "recvTransportId": ")" << this->recvTransportId << "\"";
}
if (!this->sendTransportId.empty())
{
std::cout << R"(, "sendTransportId": ")" << this->sendTransportId << "\"";
}
if (!this->routerId.empty())
{
std::cout << R"(, "routerId": ")" << this->routerId << "\"";
}
if (!this->producerId.empty())
{
std::cout << R"(, "producerId": ")" << this->producerId << "\"";
}
if (!this->consumerId.empty())
{
std::cout << R"(, "consumerId": ")" << this->consumerId << "\"";
}
std::cout << ", \"recvRtpTimestamp\": " << this->recvRtpTimestamp;
std::cout << ", \"sendRtpTimestamp\": " << this->sendRtpTimestamp;
std::cout << ", \"recvSeqNumber\": " << this->recvSeqNumber;
std::cout << ", \"sendSeqNumber\": " << this->sendSeqNumber;
std::cout << ", \"discarded\": " << (this->discarded ? "true" : "false");
std::cout << ", \"discardReason\": '" << discardReason2String[this->discardReason] << "'";
std::cout << "}" << std::endl;
}
void RtpPacket::Clear()
{
MS_TRACE();
this->sendTransportId = {};
this->routerId = {};
this->producerId = {};
this->sendSeqNumber = { 0 };
this->discarded = { false };
this->discardReason = { DiscardReason::NONE };
}
} // namespace RtcLogger
} // namespace RTC