mediasoup 3.11.21 → 3.11.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node/lib/Worker.js +1 -1
- package/node/lib/index.d.ts +1 -1
- package/node/lib/index.js +1 -1
- package/package.json +1 -1
- package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc +20 -1
- package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.h +3 -0
- package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe.cc +2 -2
- package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +1 -1
- package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/trendline_estimator.cc +113 -106
- package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/trendline_estimator.h +47 -26
- package/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.cc +8 -5
- package/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.h +1 -0
- package/worker/include/RTC/RtcLogger.hpp +58 -0
- package/worker/include/RTC/RtpPacket.hpp +4 -0
- package/worker/include/RTC/RtpStreamRecv.hpp +3 -1
- package/worker/include/RTC/SeqManager.hpp +0 -1
- package/worker/meson.build +7 -0
- package/worker/meson_options.txt +1 -0
- package/worker/src/RTC/PipeConsumer.cpp +15 -0
- package/worker/src/RTC/Producer.cpp +14 -1
- package/worker/src/RTC/Router.cpp +2 -0
- package/worker/src/RTC/RtcLogger.cpp +101 -0
- package/worker/src/RTC/RtpPacket.cpp +9 -0
- package/worker/src/RTC/RtpStreamRecv.cpp +14 -11
- package/worker/src/RTC/SeqManager.cpp +48 -65
- package/worker/src/RTC/SimpleConsumer.cpp +17 -0
- package/worker/src/RTC/SimulcastConsumer.cpp +34 -0
- package/worker/src/RTC/SvcConsumer.cpp +19 -0
- package/worker/src/RTC/Transport.cpp +7 -0
- package/worker/test/src/RTC/TestRtpStreamRecv.cpp +4 -3
- package/worker/test/src/RTC/TestSeqManager.cpp +80 -83
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include "common.hpp"
|
|
5
5
|
#include "Utils.hpp"
|
|
6
6
|
#include "RTC/Codecs/PayloadDescriptorHandler.hpp"
|
|
7
|
+
#include "RTC/RtcLogger.hpp"
|
|
7
8
|
#include <absl/container/flat_hash_map.h>
|
|
8
9
|
#include <array>
|
|
9
10
|
#include <nlohmann/json.hpp>
|
|
@@ -606,6 +607,9 @@ namespace RTC
|
|
|
606
607
|
|
|
607
608
|
void ShiftPayload(size_t payloadOffset, size_t shift, bool expand = true);
|
|
608
609
|
|
|
610
|
+
public:
|
|
611
|
+
RtcLogger::RtpPacket logger;
|
|
612
|
+
|
|
609
613
|
private:
|
|
610
614
|
void ParseExtensions();
|
|
611
615
|
|
|
@@ -45,7 +45,8 @@ namespace RTC
|
|
|
45
45
|
RtpStreamRecv(
|
|
46
46
|
RTC::RtpStreamRecv::Listener* listener,
|
|
47
47
|
RTC::RtpStream::Params& params,
|
|
48
|
-
unsigned int sendNackDelayMs
|
|
48
|
+
unsigned int sendNackDelayMs,
|
|
49
|
+
bool useRtpInactivityCheck);
|
|
49
50
|
~RtpStreamRecv();
|
|
50
51
|
|
|
51
52
|
void FillJsonStats(json& jsonObject) override;
|
|
@@ -96,6 +97,7 @@ namespace RTC
|
|
|
96
97
|
private:
|
|
97
98
|
// Passed by argument.
|
|
98
99
|
unsigned int sendNackDelayMs{ 0u };
|
|
100
|
+
bool useRtpInactivityCheck{ false };
|
|
99
101
|
// Others.
|
|
100
102
|
// Packets expected at last interval.
|
|
101
103
|
uint32_t expectedPrior{ 0u };
|
package/worker/meson.build
CHANGED
|
@@ -38,6 +38,12 @@ if get_option('ms_log_file_line')
|
|
|
38
38
|
]
|
|
39
39
|
endif
|
|
40
40
|
|
|
41
|
+
if get_option('ms_rtc_logger_rtp')
|
|
42
|
+
cpp_args += [
|
|
43
|
+
'-DMS_RTC_LOGGER_RTP',
|
|
44
|
+
]
|
|
45
|
+
endif
|
|
46
|
+
|
|
41
47
|
common_sources = [
|
|
42
48
|
'src/lib.cpp',
|
|
43
49
|
'src/DepLibSRTP.cpp',
|
|
@@ -85,6 +91,7 @@ common_sources = [
|
|
|
85
91
|
'src/RTC/Producer.cpp',
|
|
86
92
|
'src/RTC/RateCalculator.cpp',
|
|
87
93
|
'src/RTC/Router.cpp',
|
|
94
|
+
'src/RTC/RtcLogger.cpp',
|
|
88
95
|
'src/RTC/RtpListener.cpp',
|
|
89
96
|
'src/RTC/RtpObserver.cpp',
|
|
90
97
|
'src/RTC/RtpPacket.cpp',
|
package/worker/meson_options.txt
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
option('ms_log_trace', type : 'boolean', value : false, description : 'When enabled, logs the current method/function if current log level is "debug"')
|
|
2
2
|
option('ms_log_file_line', type : 'boolean', value : false, description : 'When enabled, all the logging macros print more verbose information, including current file and line')
|
|
3
|
+
option('ms_rtc_logger_rtp', type : 'boolean', value : false, description : 'When enabled, prints a line with information for each RTP packet')
|
|
@@ -201,8 +201,14 @@ namespace RTC
|
|
|
201
201
|
{
|
|
202
202
|
MS_TRACE();
|
|
203
203
|
|
|
204
|
+
packet->logger.consumerId = this->id;
|
|
205
|
+
|
|
204
206
|
if (!IsActive())
|
|
207
|
+
{
|
|
208
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
|
|
209
|
+
|
|
205
210
|
return;
|
|
211
|
+
}
|
|
206
212
|
|
|
207
213
|
auto payloadType = packet->GetPayloadType();
|
|
208
214
|
|
|
@@ -212,6 +218,8 @@ namespace RTC
|
|
|
212
218
|
{
|
|
213
219
|
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
|
|
214
220
|
|
|
221
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
|
|
222
|
+
|
|
215
223
|
return;
|
|
216
224
|
}
|
|
217
225
|
|
|
@@ -223,7 +231,11 @@ namespace RTC
|
|
|
223
231
|
// If we need to sync, support key frames and this is not a key frame, ignore
|
|
224
232
|
// the packet.
|
|
225
233
|
if (syncRequired && this->keyFrameSupported && !packet->IsKeyFrame())
|
|
234
|
+
{
|
|
235
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
|
|
236
|
+
|
|
226
237
|
return;
|
|
238
|
+
}
|
|
227
239
|
|
|
228
240
|
// Whether this is the first packet after re-sync.
|
|
229
241
|
const bool isSyncPacket = syncRequired;
|
|
@@ -252,6 +264,9 @@ namespace RTC
|
|
|
252
264
|
packet->SetSsrc(ssrc);
|
|
253
265
|
packet->SetSequenceNumber(seq);
|
|
254
266
|
|
|
267
|
+
packet->logger.sendRtpTimestamp = packet->GetTimestamp();
|
|
268
|
+
packet->logger.sendSeqNumber = seq;
|
|
269
|
+
|
|
255
270
|
if (isSyncPacket)
|
|
256
271
|
{
|
|
257
272
|
MS_DEBUG_TAG(
|
|
@@ -672,6 +672,8 @@ namespace RTC
|
|
|
672
672
|
{
|
|
673
673
|
MS_TRACE();
|
|
674
674
|
|
|
675
|
+
packet->logger.producerId = this->id;
|
|
676
|
+
|
|
675
677
|
// Reset current packet.
|
|
676
678
|
this->currentRtpPacket = nullptr;
|
|
677
679
|
|
|
@@ -684,6 +686,8 @@ namespace RTC
|
|
|
684
686
|
{
|
|
685
687
|
MS_WARN_TAG(rtp, "no stream found for received packet [ssrc:%" PRIu32 "]", packet->GetSsrc());
|
|
686
688
|
|
|
689
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_NOT_FOUND);
|
|
690
|
+
|
|
687
691
|
return ReceiveRtpPacketResult::DISCARDED;
|
|
688
692
|
}
|
|
689
693
|
|
|
@@ -705,6 +709,8 @@ namespace RTC
|
|
|
705
709
|
if (this->mapSsrcRtpStream.size() > numRtpStreamsBefore)
|
|
706
710
|
NotifyNewRtpStream(rtpStream);
|
|
707
711
|
|
|
712
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_DISCARDED);
|
|
713
|
+
|
|
708
714
|
return result;
|
|
709
715
|
}
|
|
710
716
|
}
|
|
@@ -716,7 +722,11 @@ namespace RTC
|
|
|
716
722
|
|
|
717
723
|
// Process the packet.
|
|
718
724
|
if (!rtpStream->ReceiveRtxPacket(packet))
|
|
725
|
+
{
|
|
726
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_NOT_FOUND);
|
|
727
|
+
|
|
719
728
|
return result;
|
|
729
|
+
}
|
|
720
730
|
}
|
|
721
731
|
// Should not happen.
|
|
722
732
|
else
|
|
@@ -1213,8 +1223,11 @@ namespace RTC
|
|
|
1213
1223
|
}
|
|
1214
1224
|
}
|
|
1215
1225
|
|
|
1226
|
+
// Only perform RTP inactivity check on simulcast.
|
|
1227
|
+
auto useRtpInactivityCheck = this->type == RtpParameters::Type::SIMULCAST;
|
|
1228
|
+
|
|
1216
1229
|
// Create a RtpStreamRecv for receiving a media stream.
|
|
1217
|
-
auto* rtpStream = new RTC::RtpStreamRecv(this, params, SendNackDelay);
|
|
1230
|
+
auto* rtpStream = new RTC::RtpStreamRecv(this, params, SendNackDelay, useRtpInactivityCheck);
|
|
1218
1231
|
|
|
1219
1232
|
// Insert into the maps.
|
|
1220
1233
|
this->mapSsrcRtpStream[ssrc] = rtpStream;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#define MS_CLASS "RTC::RtcLogger"
|
|
2
|
+
// #define MS_LOG_DEV_LEVEL 3
|
|
3
|
+
|
|
4
|
+
#include "RTC/RtcLogger.hpp"
|
|
5
|
+
#include "Logger.hpp"
|
|
6
|
+
|
|
7
|
+
namespace RTC
|
|
8
|
+
{
|
|
9
|
+
namespace RtcLogger
|
|
10
|
+
{
|
|
11
|
+
// clang-format off
|
|
12
|
+
absl::flat_hash_map<RtpPacket::DropReason, std::string> RtpPacket::dropReason2String = {
|
|
13
|
+
{ RtpPacket::DropReason::NONE, "None" },
|
|
14
|
+
{ RtpPacket::DropReason::PRODUCER_NOT_FOUND, "ProducerNotFound" },
|
|
15
|
+
{ RtpPacket::DropReason::RECV_RTP_STREAM_NOT_FOUND, "RecvRtpStreamNotFound" },
|
|
16
|
+
{ RtpPacket::DropReason::RECV_RTP_STREAM_DISCARDED, "RecvRtpStreamDiscarded" },
|
|
17
|
+
{ RtpPacket::DropReason::CONSUMER_INACTIVE, "ConsumerInactive" },
|
|
18
|
+
{ RtpPacket::DropReason::INVALID_TARGET_LAYER, "InvalidTargetLayer" },
|
|
19
|
+
{ RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE, "UnsupportedPayloadType" },
|
|
20
|
+
{ RtpPacket::DropReason::NOT_A_KEYFRAME, "NotAKeyframe" },
|
|
21
|
+
{ RtpPacket::DropReason::SPATIAL_LAYER_MISMATCH, "SpatialLayerMismatch" },
|
|
22
|
+
{ RtpPacket::DropReason::TOO_HIGH_TIMESTAMP_EXTRA_NEEDED, "TooHighTimestampExtraNeeded" },
|
|
23
|
+
{ RtpPacket::DropReason::PACKET_PREVIOUS_TO_SPATIAL_LAYER_SWITCH, "PacketPreviousToSpatialLayerSwitch" },
|
|
24
|
+
{ RtpPacket::DropReason::DROPPED_BY_CODEC, "DroppedByCodec" },
|
|
25
|
+
{ RtpPacket::DropReason::SEND_RTP_STREAM_DISCARDED, "SendRtpStreamDiscarded" },
|
|
26
|
+
};
|
|
27
|
+
// clang-format on
|
|
28
|
+
|
|
29
|
+
void RtpPacket::Sent()
|
|
30
|
+
{
|
|
31
|
+
MS_TRACE();
|
|
32
|
+
|
|
33
|
+
this->dropped = false;
|
|
34
|
+
|
|
35
|
+
Log();
|
|
36
|
+
Clear();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void RtpPacket::Dropped(DropReason dropReason)
|
|
40
|
+
{
|
|
41
|
+
MS_TRACE();
|
|
42
|
+
|
|
43
|
+
this->dropped = true;
|
|
44
|
+
this->dropReason = dropReason;
|
|
45
|
+
|
|
46
|
+
Log();
|
|
47
|
+
Clear();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void RtpPacket::Log() const
|
|
51
|
+
{
|
|
52
|
+
#ifdef MS_RTC_LOGGER_RTP
|
|
53
|
+
MS_TRACE();
|
|
54
|
+
|
|
55
|
+
std::cout << "{";
|
|
56
|
+
std::cout << "\"timestamp\": " << this->timestamp;
|
|
57
|
+
|
|
58
|
+
if (!this->recvTransportId.empty())
|
|
59
|
+
{
|
|
60
|
+
std::cout << ", \"recvTransportId\": \"" << this->recvTransportId << "\"";
|
|
61
|
+
}
|
|
62
|
+
if (!this->sendTransportId.empty())
|
|
63
|
+
{
|
|
64
|
+
std::cout << ", \"sendTransportId\": \"" << this->sendTransportId << "\"";
|
|
65
|
+
}
|
|
66
|
+
if (!this->routerId.empty())
|
|
67
|
+
{
|
|
68
|
+
std::cout << ", \"routerId\": \"" << this->routerId << "\"";
|
|
69
|
+
}
|
|
70
|
+
if (!this->producerId.empty())
|
|
71
|
+
{
|
|
72
|
+
std::cout << ", \"producerId\": \"" << this->producerId << "\"";
|
|
73
|
+
}
|
|
74
|
+
if (!this->consumerId.empty())
|
|
75
|
+
{
|
|
76
|
+
std::cout << ", \"consumerId\": \"" << this->consumerId << "\"";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
std::cout << ", \"recvRtpTimestamp\": " << this->recvRtpTimestamp;
|
|
80
|
+
std::cout << ", \"sendRtpTimestamp\": " << this->sendRtpTimestamp;
|
|
81
|
+
std::cout << ", \"recvSeqNumber\": " << this->recvSeqNumber;
|
|
82
|
+
std::cout << ", \"sendSeqNumber\": " << this->sendSeqNumber;
|
|
83
|
+
std::cout << ", \"dropped\": " << (this->dropped ? "true" : "false");
|
|
84
|
+
std::cout << ", \"dropReason\": '" << dropReason2String[this->dropReason] << "'";
|
|
85
|
+
std::cout << "}" << std::endl;
|
|
86
|
+
#endif
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
void RtpPacket::Clear()
|
|
90
|
+
{
|
|
91
|
+
MS_TRACE();
|
|
92
|
+
|
|
93
|
+
this->sendTransportId = {};
|
|
94
|
+
this->routerId = {};
|
|
95
|
+
this->producerId = {};
|
|
96
|
+
this->sendSeqNumber = { 0 };
|
|
97
|
+
this->dropped = { false };
|
|
98
|
+
this->dropReason = { DropReason::NONE };
|
|
99
|
+
}
|
|
100
|
+
} // namespace RtcLogger
|
|
101
|
+
} // namespace RTC
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// #define MS_LOG_DEV_LEVEL 3
|
|
3
3
|
|
|
4
4
|
#include "RTC/RtpPacket.hpp"
|
|
5
|
+
#include "DepLibUV.hpp"
|
|
5
6
|
#include "Logger.hpp"
|
|
6
7
|
#include <cstring> // std::memcpy(), std::memmove(), std::memset()
|
|
7
8
|
#include <iterator> // std::ostream_iterator
|
|
@@ -139,6 +140,14 @@ namespace RTC
|
|
|
139
140
|
|
|
140
141
|
// Parse RFC 5285 header extension.
|
|
141
142
|
ParseExtensions();
|
|
143
|
+
|
|
144
|
+
// Avoid retrieving the time if RTC logger is disabled.
|
|
145
|
+
#ifdef MS_RTC_LOGGER_RTP
|
|
146
|
+
// Initialize logger.
|
|
147
|
+
this->logger.timestamp = DepLibUV::GetTimeMs();
|
|
148
|
+
this->logger.recvRtpTimestamp = this->GetTimestamp();
|
|
149
|
+
this->logger.recvSeqNumber = this->GetSequenceNumber();
|
|
150
|
+
#endif
|
|
142
151
|
}
|
|
143
152
|
|
|
144
153
|
RtpPacket::~RtpPacket()
|
|
@@ -189,8 +189,12 @@ namespace RTC
|
|
|
189
189
|
/* Instance methods. */
|
|
190
190
|
|
|
191
191
|
RtpStreamRecv::RtpStreamRecv(
|
|
192
|
-
RTC::RtpStreamRecv::Listener* listener,
|
|
192
|
+
RTC::RtpStreamRecv::Listener* listener,
|
|
193
|
+
RTC::RtpStream::Params& params,
|
|
194
|
+
unsigned int sendNackDelayMs,
|
|
195
|
+
bool useRtpInactivityCheck)
|
|
193
196
|
: RTC::RtpStream::RtpStream(listener, params, 10), sendNackDelayMs(sendNackDelayMs),
|
|
197
|
+
useRtpInactivityCheck(useRtpInactivityCheck),
|
|
194
198
|
transmissionCounter(
|
|
195
199
|
params.spatialLayers, params.temporalLayers, this->params.useDtx ? 6000 : 2500)
|
|
196
200
|
{
|
|
@@ -201,18 +205,16 @@ namespace RTC
|
|
|
201
205
|
this->nackGenerator.reset(new RTC::NackGenerator(this, this->sendNackDelayMs));
|
|
202
206
|
}
|
|
203
207
|
|
|
204
|
-
|
|
205
|
-
// enabled).
|
|
206
|
-
this->inactivityCheckPeriodicTimer = new Timer(this);
|
|
207
|
-
this->inactive = false;
|
|
208
|
+
this->inactive = false;
|
|
208
209
|
|
|
209
|
-
if (
|
|
210
|
+
if (this->useRtpInactivityCheck)
|
|
210
211
|
{
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
this->inactivityCheckPeriodicTimer->Start(
|
|
212
|
+
// Run the RTP inactivity periodic timer (use a different timeout if DTX is
|
|
213
|
+
// enabled).
|
|
214
|
+
this->inactivityCheckPeriodicTimer = new Timer(this);
|
|
215
|
+
|
|
216
|
+
this->inactivityCheckPeriodicTimer->Start(
|
|
217
|
+
this->params.useDtx ? InactivityCheckIntervalWithDtx : InactivityCheckInterval);
|
|
216
218
|
}
|
|
217
219
|
}
|
|
218
220
|
|
|
@@ -222,6 +224,7 @@ namespace RTC
|
|
|
222
224
|
|
|
223
225
|
// Close the RTP inactivity check periodic timer.
|
|
224
226
|
delete this->inactivityCheckPeriodicTimer;
|
|
227
|
+
this->inactivityCheckPeriodicTimer = nullptr;
|
|
225
228
|
}
|
|
226
229
|
|
|
227
230
|
void RtpStreamRecv::FillJsonStats(json& jsonObject)
|
|
@@ -58,14 +58,11 @@ namespace RTC
|
|
|
58
58
|
// Mark as dropped if 'input' is higher than anyone already processed.
|
|
59
59
|
if (SeqManager<T, N>::IsSeqHigherThan(input, this->maxInput))
|
|
60
60
|
{
|
|
61
|
+
this->maxInput = input;
|
|
61
62
|
this->dropped.insert(input);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
this->base = (this->base + offset) & MaxValue;
|
|
64
|
+
ClearDropped();
|
|
65
|
+
}
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
template<typename T, uint8_t N>
|
|
@@ -73,44 +70,52 @@ namespace RTC
|
|
|
73
70
|
{
|
|
74
71
|
auto base = this->base;
|
|
75
72
|
|
|
76
|
-
//
|
|
77
|
-
if (
|
|
73
|
+
// No dropped inputs to consider.
|
|
74
|
+
if (this->dropped.empty())
|
|
75
|
+
{
|
|
76
|
+
goto done;
|
|
77
|
+
}
|
|
78
|
+
// Dropped inputs present, cleanup and update base.
|
|
79
|
+
else
|
|
78
80
|
{
|
|
79
|
-
//
|
|
80
|
-
if (this->
|
|
81
|
+
// Set 'maxInput' here if needed before calling ClearDropped().
|
|
82
|
+
if (this->started && IsSeqHigherThan(input, this->maxInput))
|
|
81
83
|
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return false;
|
|
84
|
+
this->maxInput = input;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
ClearDropped();
|
|
88
|
+
|
|
89
|
+
base = this->base;
|
|
90
|
+
}
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
// No dropped inputs to consider after cleanup.
|
|
93
|
+
if (this->dropped.empty())
|
|
94
|
+
{
|
|
95
|
+
goto done;
|
|
96
|
+
}
|
|
97
|
+
// This input was dropped.
|
|
98
|
+
else if (this->dropped.find(input) != this->dropped.end())
|
|
99
|
+
{
|
|
100
|
+
MS_DEBUG_DEV("trying to send a dropped input");
|
|
101
|
+
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
// There are dropped inputs, calculate 'base' for this input.
|
|
105
|
+
else
|
|
106
|
+
{
|
|
107
|
+
// Get the first dropped input which is higher than or equal 'input'.
|
|
108
|
+
auto it = this->dropped.lower_bound(input);
|
|
109
|
+
|
|
110
|
+
// There are dropped inputs lower than 'input'.
|
|
111
|
+
if (it != this->dropped.begin())
|
|
95
112
|
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
(
|
|
99
|
-
IsSeqLowerThan(value, input) ||
|
|
100
|
-
(
|
|
101
|
-
(value > input && (value - input > MaxValue / 3)) ||
|
|
102
|
-
(value < input && (input - value > MaxValue / 3))
|
|
103
|
-
)
|
|
104
|
-
)
|
|
105
|
-
// clang-format on
|
|
106
|
-
{
|
|
107
|
-
count++;
|
|
108
|
-
}
|
|
113
|
+
auto count = std::distance(this->dropped.begin(), it);
|
|
114
|
+
base = (this->base - count) & MaxValue;
|
|
109
115
|
}
|
|
110
|
-
|
|
111
|
-
base = (this->base - count) & MaxValue;
|
|
112
116
|
}
|
|
113
117
|
|
|
118
|
+
done:
|
|
114
119
|
output = (input + base) & MaxValue;
|
|
115
120
|
|
|
116
121
|
if (!this->started)
|
|
@@ -122,23 +127,19 @@ namespace RTC
|
|
|
122
127
|
}
|
|
123
128
|
else
|
|
124
129
|
{
|
|
125
|
-
// New input is higher than the maximum seen.
|
|
126
|
-
// Keep it as the maximum seen. See Drop().
|
|
130
|
+
// New input is higher than the maximum seen.
|
|
127
131
|
if (IsSeqHigherThan(input, this->maxInput))
|
|
128
132
|
{
|
|
129
133
|
this->maxInput = input;
|
|
130
134
|
}
|
|
131
135
|
|
|
132
|
-
// New output is higher than the maximum seen.
|
|
133
|
-
// Keep it as the maximum seen. See Sync().
|
|
136
|
+
// New output is higher than the maximum seen.
|
|
134
137
|
if (IsSeqHigherThan(output, this->maxOutput))
|
|
135
138
|
{
|
|
136
139
|
this->maxOutput = output;
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
142
|
|
|
140
|
-
ClearDropped();
|
|
141
|
-
|
|
142
143
|
return true;
|
|
143
144
|
}
|
|
144
145
|
|
|
@@ -155,7 +156,7 @@ namespace RTC
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
/*
|
|
158
|
-
* Delete droped inputs greater than maxInput
|
|
159
|
+
* Delete droped inputs greater than maxInput, which belong to a previous
|
|
159
160
|
* cycle.
|
|
160
161
|
*/
|
|
161
162
|
template<typename T, uint8_t N>
|
|
@@ -167,37 +168,19 @@ namespace RTC
|
|
|
167
168
|
return;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
const size_t threshold = (this->maxInput + MaxValue / 3) & MaxValue;
|
|
171
171
|
const size_t previousDroppedSize = this->dropped.size();
|
|
172
|
-
const auto it1 = this->dropped.upper_bound(this->maxInput);
|
|
173
|
-
const auto it2 = this->dropped.lower_bound(threshold);
|
|
174
172
|
|
|
175
|
-
|
|
176
|
-
if (it1 == this->dropped.end())
|
|
177
|
-
{
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// There is a single value in the range.
|
|
182
|
-
if (it1 == it2)
|
|
183
|
-
{
|
|
184
|
-
this->dropped.erase(it1);
|
|
185
|
-
}
|
|
186
|
-
// There are many values in the range.
|
|
187
|
-
else
|
|
173
|
+
for (auto it = this->dropped.begin(); it != this->dropped.end();)
|
|
188
174
|
{
|
|
189
|
-
|
|
190
|
-
auto distanceIt1 = std::distance(this->dropped.begin(), it1);
|
|
191
|
-
auto distanceIt2 = std::distance(this->dropped.begin(), it2);
|
|
175
|
+
auto value = *it;
|
|
192
176
|
|
|
193
|
-
|
|
194
|
-
if (distanceIt2 < distanceIt1)
|
|
177
|
+
if (isSeqHigherThan(value, this->maxInput))
|
|
195
178
|
{
|
|
196
|
-
this->dropped.erase(
|
|
179
|
+
it = this->dropped.erase(it);
|
|
197
180
|
}
|
|
198
181
|
else
|
|
199
182
|
{
|
|
200
|
-
|
|
183
|
+
break;
|
|
201
184
|
}
|
|
202
185
|
}
|
|
203
186
|
|
|
@@ -265,8 +265,14 @@ namespace RTC
|
|
|
265
265
|
{
|
|
266
266
|
MS_TRACE();
|
|
267
267
|
|
|
268
|
+
packet->logger.consumerId = this->id;
|
|
269
|
+
|
|
268
270
|
if (!IsActive())
|
|
271
|
+
{
|
|
272
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
|
|
273
|
+
|
|
269
274
|
return;
|
|
275
|
+
}
|
|
270
276
|
|
|
271
277
|
auto payloadType = packet->GetPayloadType();
|
|
272
278
|
|
|
@@ -276,6 +282,8 @@ namespace RTC
|
|
|
276
282
|
{
|
|
277
283
|
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
|
|
278
284
|
|
|
285
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
|
|
286
|
+
|
|
279
287
|
return;
|
|
280
288
|
}
|
|
281
289
|
|
|
@@ -292,13 +300,19 @@ namespace RTC
|
|
|
292
300
|
|
|
293
301
|
this->rtpSeqManager.Drop(packet->GetSequenceNumber());
|
|
294
302
|
|
|
303
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC);
|
|
304
|
+
|
|
295
305
|
return;
|
|
296
306
|
}
|
|
297
307
|
|
|
298
308
|
// If we need to sync, support key frames and this is not a key frame, ignore
|
|
299
309
|
// the packet.
|
|
300
310
|
if (this->syncRequired && this->keyFrameSupported && !packet->IsKeyFrame())
|
|
311
|
+
{
|
|
312
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
|
|
313
|
+
|
|
301
314
|
return;
|
|
315
|
+
}
|
|
302
316
|
|
|
303
317
|
// Whether this is the first packet after re-sync.
|
|
304
318
|
const bool isSyncPacket = this->syncRequired;
|
|
@@ -327,6 +341,9 @@ namespace RTC
|
|
|
327
341
|
packet->SetSsrc(this->rtpParameters.encodings[0].ssrc);
|
|
328
342
|
packet->SetSequenceNumber(seq);
|
|
329
343
|
|
|
344
|
+
packet->logger.sendRtpTimestamp = packet->GetTimestamp();
|
|
345
|
+
packet->logger.sendSeqNumber = seq;
|
|
346
|
+
|
|
330
347
|
if (isSyncPacket)
|
|
331
348
|
{
|
|
332
349
|
MS_DEBUG_TAG(
|
|
@@ -664,11 +664,21 @@ namespace RTC
|
|
|
664
664
|
{
|
|
665
665
|
MS_TRACE();
|
|
666
666
|
|
|
667
|
+
packet->logger.consumerId = this->id;
|
|
668
|
+
|
|
667
669
|
if (!IsActive())
|
|
670
|
+
{
|
|
671
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::CONSUMER_INACTIVE);
|
|
672
|
+
|
|
668
673
|
return;
|
|
674
|
+
}
|
|
669
675
|
|
|
670
676
|
if (this->targetTemporalLayer == -1)
|
|
677
|
+
{
|
|
678
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::INVALID_TARGET_LAYER);
|
|
679
|
+
|
|
671
680
|
return;
|
|
681
|
+
}
|
|
672
682
|
|
|
673
683
|
auto payloadType = packet->GetPayloadType();
|
|
674
684
|
|
|
@@ -678,6 +688,8 @@ namespace RTC
|
|
|
678
688
|
{
|
|
679
689
|
MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
|
|
680
690
|
|
|
691
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE);
|
|
692
|
+
|
|
681
693
|
return;
|
|
682
694
|
}
|
|
683
695
|
|
|
@@ -690,7 +702,11 @@ namespace RTC
|
|
|
690
702
|
{
|
|
691
703
|
// Ignore if not a key frame.
|
|
692
704
|
if (!packet->IsKeyFrame())
|
|
705
|
+
{
|
|
706
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
|
|
707
|
+
|
|
693
708
|
return;
|
|
709
|
+
}
|
|
694
710
|
|
|
695
711
|
shouldSwitchCurrentSpatialLayer = true;
|
|
696
712
|
|
|
@@ -702,12 +718,18 @@ namespace RTC
|
|
|
702
718
|
// drop it.
|
|
703
719
|
else if (spatialLayer != this->currentSpatialLayer)
|
|
704
720
|
{
|
|
721
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::SPATIAL_LAYER_MISMATCH);
|
|
722
|
+
|
|
705
723
|
return;
|
|
706
724
|
}
|
|
707
725
|
|
|
708
726
|
// If we need to sync and this is not a key frame, ignore the packet.
|
|
709
727
|
if (this->syncRequired && !packet->IsKeyFrame())
|
|
728
|
+
{
|
|
729
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME);
|
|
730
|
+
|
|
710
731
|
return;
|
|
732
|
+
}
|
|
711
733
|
|
|
712
734
|
// Whether this is the first packet after re-sync.
|
|
713
735
|
const bool isSyncPacket = this->syncRequired;
|
|
@@ -814,6 +836,8 @@ namespace RTC
|
|
|
814
836
|
this->syncRequired = false;
|
|
815
837
|
this->spatialLayerToSync = -1;
|
|
816
838
|
|
|
839
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::TOO_HIGH_TIMESTAMP_EXTRA_NEEDED);
|
|
840
|
+
|
|
817
841
|
return;
|
|
818
842
|
}
|
|
819
843
|
|
|
@@ -854,6 +878,9 @@ namespace RTC
|
|
|
854
878
|
if (SeqManager<uint16_t>::IsSeqLowerThan(
|
|
855
879
|
packet->GetSequenceNumber(), this->snReferenceSpatialLayer))
|
|
856
880
|
{
|
|
881
|
+
packet->logger.Dropped(
|
|
882
|
+
RtcLogger::RtpPacket::DropReason::PACKET_PREVIOUS_TO_SPATIAL_LAYER_SWITCH);
|
|
883
|
+
|
|
857
884
|
return;
|
|
858
885
|
}
|
|
859
886
|
else if (SeqManager<uint16_t>::IsSeqHigherThan(
|
|
@@ -898,6 +925,8 @@ namespace RTC
|
|
|
898
925
|
{
|
|
899
926
|
this->rtpSeqManager.Drop(packet->GetSequenceNumber());
|
|
900
927
|
|
|
928
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::DROPPED_BY_CODEC);
|
|
929
|
+
|
|
901
930
|
return;
|
|
902
931
|
}
|
|
903
932
|
|
|
@@ -921,6 +950,9 @@ namespace RTC
|
|
|
921
950
|
packet->SetSequenceNumber(seq);
|
|
922
951
|
packet->SetTimestamp(timestamp);
|
|
923
952
|
|
|
953
|
+
packet->logger.sendRtpTimestamp = timestamp;
|
|
954
|
+
packet->logger.sendSeqNumber = seq;
|
|
955
|
+
|
|
924
956
|
if (isSyncPacket)
|
|
925
957
|
{
|
|
926
958
|
MS_DEBUG_TAG(
|
|
@@ -959,6 +991,8 @@ namespace RTC
|
|
|
959
991
|
origSsrc,
|
|
960
992
|
origSeq,
|
|
961
993
|
origTimestamp);
|
|
994
|
+
|
|
995
|
+
packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::SEND_RTP_STREAM_DISCARDED);
|
|
962
996
|
}
|
|
963
997
|
|
|
964
998
|
// Restore packet fields.
|