mediasoup 3.10.7 → 3.10.8

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.
Files changed (38) hide show
  1. package/node/lib/WebRtcServer.d.ts +1 -1
  2. package/node/lib/WebRtcServer.d.ts.map +1 -1
  3. package/node/lib/Worker.js +1 -1
  4. package/node/lib/index.d.ts +1 -1
  5. package/node/lib/index.js +1 -1
  6. package/package.json +2 -2
  7. package/worker/fuzzer/src/RTC/FuzzerRtpStreamSend.cpp +1 -1
  8. package/worker/include/RTC/Consumer.hpp +3 -1
  9. package/worker/include/RTC/DtlsTransport.hpp +1 -1
  10. package/worker/include/RTC/RtpPacket.hpp +1 -1
  11. package/worker/src/RTC/ActiveSpeakerObserver.cpp +6 -6
  12. package/worker/src/RTC/Consumer.cpp +8 -2
  13. package/worker/src/RTC/DataConsumer.cpp +2 -2
  14. package/worker/src/RTC/DtlsTransport.cpp +1 -1
  15. package/worker/src/RTC/IceServer.cpp +12 -6
  16. package/worker/src/RTC/PipeConsumer.cpp +1 -1
  17. package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +1 -1
  18. package/worker/src/RTC/RtpPacket.cpp +9 -9
  19. package/worker/src/RTC/SctpAssociation.cpp +1 -1
  20. package/worker/src/RTC/SimpleConsumer.cpp +1 -1
  21. package/worker/src/RTC/SimulcastConsumer.cpp +2 -2
  22. package/worker/src/RTC/SvcConsumer.cpp +1 -1
  23. package/worker/src/RTC/TcpServer.cpp +1 -1
  24. package/worker/src/RTC/Transport.cpp +1 -1
  25. package/worker/src/RTC/UdpSocket.cpp +1 -2
  26. package/worker/src/RTC/WebRtcServer.cpp +22 -8
  27. package/worker/src/RTC/WebRtcTransport.cpp +2 -0
  28. package/worker/test/src/RTC/RTCP/TestBye.cpp +1 -1
  29. package/worker/test/src/RTC/RTCP/TestFeedbackPsFir.cpp +1 -1
  30. package/worker/test/src/RTC/RTCP/TestFeedbackPsLei.cpp +1 -1
  31. package/worker/test/src/RTC/RTCP/TestFeedbackPsTst.cpp +1 -1
  32. package/worker/test/src/RTC/RTCP/TestFeedbackRtpNack.cpp +1 -1
  33. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
  34. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +2 -5
  35. package/worker/test/src/RTC/RTCP/TestSdes.cpp +1 -1
  36. package/worker/test/src/RTC/TestNackGenerator.cpp +8 -8
  37. package/worker/test/src/RTC/TestRateCalculator.cpp +2 -3
  38. package/worker/test/src/RTC/TestRtpStreamSend.cpp +8 -8
@@ -19,7 +19,7 @@ export interface WebRtcServerListenInfo {
19
19
  /**
20
20
  * Listening port.
21
21
  */
22
- port: number;
22
+ port?: number;
23
23
  }
24
24
  export declare type WebRtcServerOptions = {
25
25
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"WebRtcServer.d.ts","sourceRoot":"","sources":["../src/WebRtcServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,sBAAsB;IAEtC;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAC;IAE5B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACb;AAED,oBAAY,mBAAmB,GAC/B;IACC;;OAEG;IACH,WAAW,EAAE,sBAAsB,EAAE,CAAC;IAEtC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,oBAAY,kBAAkB,GAC9B;IACC,WAAW,EAAE,EAA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;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAGpB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGrC;IAED;;OAEG;IACH,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAG3C;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAG/D;IAED;;;OAGG;IACH,IAAI,0BAA0B,IAAI,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAG7D;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;IA8Bb;;;;OAIG;IACH,YAAY,IAAI,IAAI;IAmBpB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAO1B;;OAEG;IACH,qBAAqB,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;CAe7D"}
@@ -81,7 +81,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
81
81
  // options
82
82
  {
83
83
  env: {
84
- MEDIASOUP_VERSION: '3.10.7',
84
+ MEDIASOUP_VERSION: '3.10.8',
85
85
  // Let the worker process inherit all environment variables, useful
86
86
  // if a custom and not in the path GCC is used so the user can set
87
87
  // LD_LIBRARY_PATH environment variable for runtime.
@@ -9,7 +9,7 @@ export { types };
9
9
  /**
10
10
  * Expose mediasoup version.
11
11
  */
12
- export declare const version = "3.10.7";
12
+ export declare const version = "3.10.8";
13
13
  /**
14
14
  * Expose parseScalabilityMode() function.
15
15
  */
package/node/lib/index.js CHANGED
@@ -11,7 +11,7 @@ exports.types = types;
11
11
  /**
12
12
  * Expose mediasoup version.
13
13
  */
14
- exports.version = '3.10.7';
14
+ exports.version = '3.10.8';
15
15
  /**
16
16
  * Expose parseScalabilityMode() function.
17
17
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup",
3
- "version": "3.10.7",
3
+ "version": "3.10.8",
4
4
  "description": "Cutting Edge WebRTC Video Conferencing",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -88,6 +88,6 @@
88
88
  "pick-port": "^1.0.1",
89
89
  "sctp": "^1.0.0",
90
90
  "tsc-watch": "^5.0.3",
91
- "typescript": "^4.8.3"
91
+ "typescript": "^4.8.4"
92
92
  }
93
93
  }
@@ -43,7 +43,7 @@ void Fuzzer::RTC::RtpStreamSend::Fuzz(const uint8_t* data, size_t len)
43
43
  packet->SetSsrc(params.ssrc);
44
44
 
45
45
  std::string mid;
46
- ::RTC::RtpStreamSend* stream = new ::RTC::RtpStreamSend(&testRtpStreamListener, params, mid);
46
+ auto* stream = new ::RTC::RtpStreamSend(&testRtpStreamListener, params, mid);
47
47
 
48
48
  while (len >= 4u)
49
49
  {
@@ -187,7 +187,9 @@ namespace RTC
187
187
  struct RTC::RtpHeaderExtensionIds rtpHeaderExtensionIds;
188
188
  const std::vector<uint8_t>* producerRtpStreamScores{ nullptr };
189
189
  // Others.
190
- absl::flat_hash_set<uint8_t> supportedCodecPayloadTypes;
190
+ // Whether a payload type is supported or not is represented in the
191
+ // corresponding position of the bitset.
192
+ std::bitset<128u> supportedCodecPayloadTypes;
191
193
  uint64_t lastRtcpSentTime{ 0u };
192
194
  uint16_t maxRtcpInterval{ 0u };
193
195
  bool externallyManagedBitrate{ false };
@@ -161,7 +161,7 @@ namespace RTC
161
161
  {
162
162
  return DtlsTransport::localFingerprints;
163
163
  }
164
- bool SetRemoteFingerprint(Fingerprint fingerprint);
164
+ bool SetRemoteFingerprint(const Fingerprint& fingerprint);
165
165
  void ProcessDtlsData(const uint8_t* data, size_t len);
166
166
  DtlsState GetState() const
167
167
  {
@@ -315,7 +315,7 @@ namespace RTC
315
315
  return true;
316
316
  }
317
317
 
318
- bool UpdateMid(const std::string& mid);
318
+ void UpdateMid(const std::string& mid);
319
319
 
320
320
  bool ReadRid(std::string& rid) const
321
321
  {
@@ -308,10 +308,10 @@ namespace RTC
308
308
  dominantSpeaker->EvalActivityScores();
309
309
  double newDominantC2 = C2;
310
310
 
311
- for (auto it = this->mapProducerSpeaker.begin(); it != this->mapProducerSpeaker.end(); ++it)
311
+ for (const auto& it : this->mapProducerSpeaker)
312
312
  {
313
- Speaker* speaker = it->second.speaker;
314
- const std::string& id = it->second.producer->id;
313
+ Speaker* speaker = it.second.speaker;
314
+ const std::string& id = it.second.producer->id;
315
315
 
316
316
  if (id == this->dominantId || speaker->paused)
317
317
  {
@@ -351,10 +351,10 @@ namespace RTC
351
351
  {
352
352
  MS_TRACE();
353
353
 
354
- for (auto it = this->mapProducerSpeaker.begin(); it != this->mapProducerSpeaker.end(); ++it)
354
+ for (const auto& it : this->mapProducerSpeaker)
355
355
  {
356
- Speaker* speaker = it->second.speaker;
357
- const std::string& id = it->second.producer->id;
356
+ Speaker* speaker = it.second.speaker;
357
+ const std::string& id = it.second.producer->id;
358
358
  uint64_t idle = now - speaker->lastLevelChangeTime;
359
359
 
360
360
  if (SpeakerIdleTimeout < idle && (this->dominantId.empty() || id != this->dominantId))
@@ -130,7 +130,7 @@ namespace RTC
130
130
  for (auto& codec : this->rtpParameters.codecs)
131
131
  {
132
132
  if (codec.mimeType.IsMediaCodec())
133
- this->supportedCodecPayloadTypes.insert(codec.payloadType);
133
+ this->supportedCodecPayloadTypes[codec.payloadType] = true;
134
134
  }
135
135
 
136
136
  // Fill media SSRCs vector.
@@ -192,7 +192,13 @@ namespace RTC
192
192
  }
193
193
 
194
194
  // Add supportedCodecPayloadTypes.
195
- jsonObject["supportedCodecPayloadTypes"] = this->supportedCodecPayloadTypes;
195
+ jsonObject["supportedCodecPayloadTypes"] = json::array();
196
+
197
+ for (auto i = 0; i < 128; ++i)
198
+ {
199
+ if (this->supportedCodecPayloadTypes[i])
200
+ jsonObject["supportedCodecPayloadTypes"].push_back(i);
201
+ }
196
202
 
197
203
  // Add paused.
198
204
  jsonObject["paused"] = this->paused;
@@ -209,7 +209,7 @@ namespace RTC
209
209
  // Trigger 'bufferedamountlow' now.
210
210
  if (this->bufferedAmount <= this->bufferedAmountLowThreshold)
211
211
  {
212
- std::string data("{\"bufferedAmount\":\"");
212
+ std::string data(R"({"bufferedAmount":")");
213
213
 
214
214
  data.append(std::to_string(this->bufferedAmount));
215
215
  data.append("\"}");
@@ -350,7 +350,7 @@ namespace RTC
350
350
  this->forceTriggerBufferedAmountLow = false;
351
351
 
352
352
  // Notify the Node DataConsumer.
353
- std::string data("{\"bufferedAmount\":\"");
353
+ std::string data(R"({"bufferedAmount":")");
354
354
 
355
355
  data.append(std::to_string(this->bufferedAmount));
356
356
  data.append("\"}");
@@ -702,7 +702,7 @@ namespace RTC
702
702
  }
703
703
  }
704
704
 
705
- bool DtlsTransport::SetRemoteFingerprint(Fingerprint fingerprint)
705
+ bool DtlsTransport::SetRemoteFingerprint(const Fingerprint& fingerprint)
706
706
  {
707
707
  MS_TRACE();
708
708
 
@@ -46,6 +46,8 @@ namespace RTC
46
46
  // Notify the listener.
47
47
  this->listener->OnIceServerTupleRemoved(this, storedTuple);
48
48
  }
49
+
50
+ this->tuples.clear();
49
51
  }
50
52
 
51
53
  void IceServer::ProcessStunPacket(RTC::StunPacket* packet, RTC::TransportTuple* tuple)
@@ -294,7 +296,12 @@ namespace RTC
294
296
  if (!removedTuple)
295
297
  return;
296
298
 
299
+ // Notify the listener.
300
+ this->listener->OnIceServerTupleRemoved(this, removedTuple);
301
+
297
302
  // Remove it from the list of tuples.
303
+ // NOTE: Do it after notifying the listener since the listener may need to
304
+ // use/read the tuple being removed so we cannot free it yet.
298
305
  this->tuples.erase(it);
299
306
 
300
307
  // If this is the selected tuple, do things.
@@ -316,9 +323,6 @@ namespace RTC
316
323
  this->listener->OnIceServerDisconnected(this);
317
324
  }
318
325
  }
319
-
320
- // Notify the listener.
321
- this->listener->OnIceServerTupleRemoved(this, removedTuple);
322
326
  }
323
327
 
324
328
  void IceServer::ForceSelectedTuple(const RTC::TransportTuple* tuple)
@@ -591,13 +595,15 @@ namespace RTC
591
595
  // This should not happen by design.
592
596
  MS_ASSERT(removedTuple, "couldn't find any tuple to be removed");
593
597
 
598
+ // Notify the listener.
599
+ this->listener->OnIceServerTupleRemoved(this, removedTuple);
600
+
594
601
  // Remove it from the list of tuples.
602
+ // NOTE: Do it after notifying the listener since the listener may need to
603
+ // use/read the tuple being removed so we cannot free it yet.
595
604
  // NOTE: This trick is needed since it is a reverse_iterator and
596
605
  // erase() requires a iterator, const_iterator or bidirectional_iterator.
597
606
  this->tuples.erase(std::next(it).base());
598
-
599
- // Notify the listener.
600
- this->listener->OnIceServerTupleRemoved(this, removedTuple);
601
607
  }
602
608
 
603
609
  // Return the address of the inserted tuple.
@@ -205,7 +205,7 @@ namespace RTC
205
205
 
206
206
  // NOTE: This may happen if this Consumer supports just some codecs of those
207
207
  // in the corresponding Producer.
208
- if (this->supportedCodecPayloadTypes.find(payloadType) == this->supportedCodecPayloadTypes.end())
208
+ if (!this->supportedCodecPayloadTypes[payloadType])
209
209
  {
210
210
  MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
211
211
 
@@ -392,7 +392,7 @@ namespace RTC
392
392
  }
393
393
 
394
394
  size_t deltaIdx{ 0u };
395
- int64_t currentReceivedAtMs = static_cast<int64_t>(this->referenceTime * 64);
395
+ auto currentReceivedAtMs = static_cast<int64_t>(this->referenceTime * 64);
396
396
 
397
397
  for (size_t idx{ 0u }; idx < packetResults.size(); ++idx)
398
398
  {
@@ -533,7 +533,7 @@ namespace RTC
533
533
  MS_ASSERT(ptr == this->payload, "wrong ptr calculation");
534
534
  }
535
535
 
536
- bool RtpPacket::UpdateMid(const std::string& mid)
536
+ void RtpPacket::UpdateMid(const std::string& mid)
537
537
  {
538
538
  MS_TRACE();
539
539
 
@@ -541,25 +541,25 @@ namespace RTC
541
541
  uint8_t* extenValue = GetExtension(this->midExtensionId, extenLen);
542
542
 
543
543
  if (!extenValue)
544
- return false;
544
+ return;
545
+
546
+ size_t midLen = mid.length();
545
547
 
546
548
  // Here we assume that there is MidMaxLength available bytes, even if now
547
549
  // they are padding bytes.
548
- if (mid.size() > RTC::MidMaxLength)
550
+ if (midLen > RTC::MidMaxLength)
549
551
  {
550
552
  MS_ERROR(
551
553
  "no enough space for MID value [MidMaxLength:%" PRIu8 ", mid:'%s']",
552
554
  RTC::MidMaxLength,
553
555
  mid.c_str());
554
556
 
555
- return false;
557
+ return;
556
558
  }
557
559
 
558
- std::memcpy(extenValue, mid.c_str(), mid.size());
559
-
560
- SetExtensionLength(this->midExtensionId, mid.size());
560
+ std::memcpy(extenValue, mid.c_str(), midLen);
561
561
 
562
- return true;
562
+ SetExtensionLength(this->midExtensionId, midLen);
563
563
  }
564
564
 
565
565
  /**
@@ -837,7 +837,7 @@ namespace RTC
837
837
  MS_ASSERT(shift <= (this->payloadLength - payloadOffset), "shift too big");
838
838
 
839
839
  uint8_t* payloadOffsetPtr = this->payload + payloadOffset;
840
- size_t shiftedLen;
840
+ size_t shiftedLen{ 0 };
841
841
 
842
842
  if (expand)
843
843
  {
@@ -392,7 +392,7 @@ namespace RTC
392
392
 
393
393
  const auto& parameters = dataConsumer->GetSctpStreamParameters();
394
394
 
395
- // Fill stcp_sendv_spa.
395
+ // Fill sctp_sendv_spa.
396
396
  struct sctp_sendv_spa spa; // NOLINT(cppcoreguidelines-pro-type-member-init)
397
397
 
398
398
  std::memset(&spa, 0, sizeof(spa));
@@ -270,7 +270,7 @@ namespace RTC
270
270
 
271
271
  // NOTE: This may happen if this Consumer supports just some codecs of those
272
272
  // in the corresponding Producer.
273
- if (this->supportedCodecPayloadTypes.find(payloadType) == this->supportedCodecPayloadTypes.end())
273
+ if (!this->supportedCodecPayloadTypes[payloadType])
274
274
  {
275
275
  MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
276
276
 
@@ -627,7 +627,7 @@ namespace RTC
627
627
  auto nowMs = DepLibUV::GetTimeMs();
628
628
  uint32_t desiredBitrate{ 0u };
629
629
 
630
- for (int sIdx{ static_cast<int>(this->producerRtpStreams.size()) - 1 }; sIdx >= 0; --sIdx)
630
+ for (size_t sIdx{ this->producerRtpStreams.size() - 1 }; sIdx >= 0; --sIdx)
631
631
  {
632
632
  auto* producerRtpStream = this->producerRtpStreams.at(sIdx);
633
633
 
@@ -665,7 +665,7 @@ namespace RTC
665
665
 
666
666
  // NOTE: This may happen if this Consumer supports just some codecs of those
667
667
  // in the corresponding Producer.
668
- if (this->supportedCodecPayloadTypes.find(payloadType) == this->supportedCodecPayloadTypes.end())
668
+ if (!this->supportedCodecPayloadTypes[payloadType])
669
669
  {
670
670
  MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
671
671
 
@@ -563,7 +563,7 @@ namespace RTC
563
563
 
564
564
  // NOTE: This may happen if this Consumer supports just some codecs of those
565
565
  // in the corresponding Producer.
566
- if (this->supportedCodecPayloadTypes.find(payloadType) == this->supportedCodecPayloadTypes.end())
566
+ if (!this->supportedCodecPayloadTypes[payloadType])
567
567
  {
568
568
  MS_DEBUG_DEV("payload type not supported [payloadType:%" PRIu8 "]", payloadType);
569
569
 
@@ -13,7 +13,7 @@ namespace RTC
13
13
  TcpServer::TcpServer(Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip)
14
14
  : // This may throw.
15
15
  ::TcpServerHandler::TcpServerHandler(RTC::PortManager::BindTcp(ip)), listener(listener),
16
- connListener(connListener), fixedPort(false)
16
+ connListener(connListener)
17
17
  {
18
18
  MS_TRACE();
19
19
  }
@@ -2145,7 +2145,7 @@ namespace RTC
2145
2145
  case RTC::RTCP::Type::SDES:
2146
2146
  {
2147
2147
  // According to RFC 3550 section 6.1 "a CNAME item MUST be included in
2148
- // in each compound RTCP packet". So this is true even for compound
2148
+ // each compound RTCP packet". So this is true even for compound
2149
2149
  // packets sent by endpoints that are not sending any RTP stream to us
2150
2150
  // (thus chunks in such a SDES will have an SSCR does not match with
2151
2151
  // any Producer created in this Transport).
@@ -12,8 +12,7 @@ namespace RTC
12
12
 
13
13
  UdpSocket::UdpSocket(Listener* listener, std::string& ip)
14
14
  : // This may throw.
15
- ::UdpSocketHandler::UdpSocketHandler(PortManager::BindUdp(ip)), listener(listener),
16
- fixedPort(false)
15
+ ::UdpSocketHandler::UdpSocketHandler(PortManager::BindUdp(ip)), listener(listener)
17
16
  {
18
17
  MS_TRACE();
19
18
  }
@@ -94,14 +94,18 @@ namespace RTC
94
94
  listenInfo.announcedIp.assign(jsonAnnouncedIpIt->get<std::string>());
95
95
  }
96
96
 
97
+ uint16_t port{ 0 };
97
98
  auto jsonPortIt = jsonListenInfo.find("port");
98
99
 
99
- if (jsonPortIt == jsonListenInfo.end())
100
- MS_THROW_TYPE_ERROR("missing listenInfo.port");
101
- else if (!(jsonPortIt->is_number() && Utils::Json::IsPositiveInteger(*jsonPortIt)))
102
- MS_THROW_TYPE_ERROR("wrong listenInfo.port (not a positive number)");
100
+ if (jsonPortIt != jsonListenInfo.end())
101
+ {
102
+ if (!(jsonPortIt->is_number() && Utils::Json::IsPositiveInteger(*jsonPortIt)))
103
+ MS_THROW_TYPE_ERROR("wrong port (not a positive number)");
104
+
105
+ port = jsonPortIt->get<uint16_t>();
106
+ }
103
107
 
104
- listenInfo.port = jsonPortIt->get<uint16_t>();
108
+ listenInfo.port = port;
105
109
  }
106
110
 
107
111
  try
@@ -111,14 +115,24 @@ namespace RTC
111
115
  if (listenInfo.protocol == RTC::TransportTuple::Protocol::UDP)
112
116
  {
113
117
  // This may throw.
114
- auto* udpSocket = new RTC::UdpSocket(this, listenInfo.ip, listenInfo.port);
118
+ RTC::UdpSocket* udpSocket;
119
+
120
+ if (listenInfo.port != 0)
121
+ udpSocket = new RTC::UdpSocket(this, listenInfo.ip, listenInfo.port);
122
+ else
123
+ udpSocket = new RTC::UdpSocket(this, listenInfo.ip);
115
124
 
116
125
  this->udpSocketOrTcpServers.emplace_back(udpSocket, nullptr, listenInfo.announcedIp);
117
126
  }
118
127
  else if (listenInfo.protocol == RTC::TransportTuple::Protocol::TCP)
119
128
  {
120
129
  // This may throw.
121
- auto* tcpServer = new RTC::TcpServer(this, this, listenInfo.ip, listenInfo.port);
130
+ RTC::TcpServer* tcpServer;
131
+
132
+ if (listenInfo.port != 0)
133
+ tcpServer = new RTC::TcpServer(this, this, listenInfo.ip, listenInfo.port);
134
+ else
135
+ tcpServer = new RTC::TcpServer(this, this, listenInfo.ip);
122
136
 
123
137
  this->udpSocketOrTcpServers.emplace_back(nullptr, tcpServer, listenInfo.announcedIp);
124
138
  }
@@ -347,7 +361,7 @@ namespace RTC
347
361
  // before the ":" symbol.
348
362
 
349
363
  auto& username = packet->GetUsername();
350
- size_t colonPos = username.find(":");
364
+ size_t colonPos = username.find(':');
351
365
 
352
366
  // If no colon is found just return the whole USERNAME attribute anyway.
353
367
  if (colonPos == std::string::npos)
@@ -1278,7 +1278,9 @@ namespace RTC
1278
1278
 
1279
1279
  // If this is a TCP tuple, close its underlaying TCP connection.
1280
1280
  if (tuple->GetProtocol() == RTC::TransportTuple::Protocol::TCP && !tuple->IsClosed())
1281
+ {
1281
1282
  tuple->Close();
1283
+ }
1282
1284
  }
1283
1285
 
1284
1286
  inline void WebRtcTransport::OnIceServerSelectedTuple(
@@ -31,7 +31,7 @@ namespace TestBye
31
31
  {
32
32
  REQUIRE(packet->GetReason() == reason);
33
33
 
34
- ByePacket::Iterator it = packet->Begin();
34
+ auto it = packet->Begin();
35
35
 
36
36
  REQUIRE(*it == ssrc1);
37
37
 
@@ -69,7 +69,7 @@ SCENARIO("RTCP Feedback PS FIR parsing", "[parser][rtcp][feedback-ps][fir]")
69
69
  {
70
70
  FeedbackPsFirPacket packet(senderSsrc, mediaSsrc);
71
71
 
72
- FeedbackPsFirItem* item = new FeedbackPsFirItem(ssrc, seq);
72
+ auto* item = new FeedbackPsFirItem(ssrc, seq);
73
73
 
74
74
  packet.AddItem(item);
75
75
 
@@ -66,7 +66,7 @@ SCENARIO("RTCP Feedback PS LEI parsing", "[parser][rtcp][feedback-ps][lei]")
66
66
  {
67
67
  FeedbackPsLeiPacket packet(senderSsrc, mediaSsrc);
68
68
 
69
- FeedbackPsLeiItem* item = new FeedbackPsLeiItem(ssrc);
69
+ auto* item = new FeedbackPsLeiItem(ssrc);
70
70
 
71
71
  packet.AddItem(item);
72
72
 
@@ -71,7 +71,7 @@ SCENARIO("RTCP Feedback PS TSTN parsing", "[parser][rtcp][feedback-ps][tstn]")
71
71
  {
72
72
  FeedbackPsTstnPacket packet(senderSsrc, mediaSsrc);
73
73
 
74
- FeedbackPsTstnItem* item = new FeedbackPsTstnItem(ssrc, seq, TestFeedbackPsTstn::index);
74
+ auto* item = new FeedbackPsTstnItem(ssrc, seq, TestFeedbackPsTstn::index);
75
75
 
76
76
  packet.AddItem(item);
77
77
 
@@ -69,7 +69,7 @@ SCENARIO("RTCP Feeback RTP NACK parsing", "[parser][rtcp][feedback-rtp][nack]")
69
69
  SECTION("create FeedbackRtpNackPacket")
70
70
  {
71
71
  FeedbackRtpNackPacket packet(senderSsrc, mediaSsrc);
72
- FeedbackRtpNackItem* item = new FeedbackRtpNackItem(pid, lostPacketBitmask);
72
+ auto* item = new FeedbackRtpNackItem(pid, lostPacketBitmask);
73
73
 
74
74
  packet.AddItem(item);
75
75
 
@@ -78,7 +78,7 @@ SCENARIO("RTCP Feeback RTP TMMBR parsing", "[parser][rtcp][feedback-rtp][tmmb]")
78
78
  SECTION("create FeedbackRtpTmmbrPacket")
79
79
  {
80
80
  FeedbackRtpTmmbrPacket packet(senderSsrc, mediaSsrc);
81
- FeedbackRtpTmmbrItem* item = new FeedbackRtpTmmbrItem();
81
+ auto* item = new FeedbackRtpTmmbrItem();
82
82
 
83
83
  item->SetSsrc(ssrc);
84
84
  item->SetBitrate(bitrate);
@@ -558,9 +558,6 @@ SCENARIO("RTCP Feeback RTP transport", "[parser][rtcp][feedback-rtp][transport]"
558
558
  FeedbackRtpTransportPacket::TimeWrapPeriod +
559
559
  static_cast<int64_t>(12408746) * FeedbackRtpTransportPacket::BaseTimeTick);
560
560
 
561
- // Let's also test the reference time reported by Wireshark.
562
- int32_t wiresharkValue{ 12408746 };
563
-
564
561
  REQUIRE(packet->GetFeedbackPacketCount() == 0);
565
562
 
566
563
  SECTION("serialize packet")
@@ -577,7 +574,7 @@ SCENARIO("RTCP Feeback RTP transport", "[parser][rtcp][feedback-rtp][transport]"
577
574
 
578
575
  SECTION("parse FeedbackRtpTransportPacket generated by Chrome with libwebrtc as a reference")
579
576
  {
580
- typedef struct
577
+ using FeedbackPacketsMeta = struct
581
578
  {
582
579
  uint32_t baseTimeRaw;
583
580
  uint64_t baseTimeMs;
@@ -585,7 +582,7 @@ SCENARIO("RTCP Feeback RTP transport", "[parser][rtcp][feedback-rtp][transport]"
585
582
  size_t packetStatusCount;
586
583
  std::vector<int16_t> deltas;
587
584
  std::vector<uint8_t> buffer;
588
- } FeedbackPacketsMeta;
585
+ };
589
586
 
590
587
  // Metadata collected by parsing buffers with libwebrtc, buffers itself.
591
588
  // were generated by chrome in direction of mediasoup.
@@ -72,7 +72,7 @@ SCENARIO("RTCP SDES parsing", "[parser][rtcp][sdes]")
72
72
 
73
73
  SECTION("create SdesChunk")
74
74
  {
75
- SdesItem* item = new SdesItem(type, length, value.c_str());
75
+ auto* item = new SdesItem(type, length, value.c_str());
76
76
 
77
77
  // Create sdes chunk.
78
78
  SdesChunk chunk(ssrc);
@@ -37,28 +37,28 @@ class TestPayloadDescriptorHandler : public Codecs::PayloadDescriptorHandler
37
37
  {
38
38
  public:
39
39
  explicit TestPayloadDescriptorHandler(bool isKeyFrame) : isKeyFrame(isKeyFrame){};
40
- ~TestPayloadDescriptorHandler() = default;
41
- void Dump() const
40
+ ~TestPayloadDescriptorHandler() override = default;
41
+ void Dump() const override
42
42
  {
43
43
  return;
44
44
  };
45
- bool Process(Codecs::EncodingContext* /*context*/, uint8_t* /*data*/, bool& /*marker*/)
45
+ bool Process(Codecs::EncodingContext* /*context*/, uint8_t* /*data*/, bool& /*marker*/) override
46
46
  {
47
47
  return true;
48
48
  };
49
- void Restore(uint8_t* /*data*/)
49
+ void Restore(uint8_t* /*data*/) override
50
50
  {
51
51
  return;
52
52
  };
53
- uint8_t GetSpatialLayer() const
53
+ uint8_t GetSpatialLayer() const override
54
54
  {
55
55
  return 0;
56
56
  };
57
- uint8_t GetTemporalLayer() const
57
+ uint8_t GetTemporalLayer() const override
58
58
  {
59
59
  return 0;
60
60
  };
61
- bool IsKeyFrame() const
61
+ bool IsKeyFrame() const override
62
62
  {
63
63
  return this->isKeyFrame;
64
64
  };
@@ -129,7 +129,7 @@ void validate(std::vector<TestNackGeneratorInput>& inputs)
129
129
  {
130
130
  listener.Reset(input);
131
131
 
132
- TestPayloadDescriptorHandler* tpdh = new TestPayloadDescriptorHandler(input.isKeyFrame);
132
+ auto* tpdh = new TestPayloadDescriptorHandler(input.isKeyFrame);
133
133
 
134
134
  packet->SetPayloadDescriptorHandler(tpdh);
135
135
  packet->SetSequenceNumber(input.seq);
@@ -15,11 +15,10 @@ struct data
15
15
 
16
16
  void validate(RateCalculator& rate, uint64_t timeBase, std::vector<data>& input)
17
17
  {
18
- for (auto it = input.begin(); it != input.end(); ++it)
18
+ for (auto& item : input)
19
19
  {
20
- auto& item = *it;
21
-
22
20
  rate.Update(item.size, timeBase + item.offset);
21
+
23
22
  REQUIRE(rate.GetRate(timeBase + item.offset) == item.rate);
24
23
  }
25
24
  }
@@ -99,7 +99,7 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
99
99
  params.mimeType.type = RTC::RtpCodecMimeType::Type::VIDEO;
100
100
 
101
101
  std::string mid;
102
- RtpStreamSend* stream = new RtpStreamSend(&testRtpStreamListener, params, mid);
102
+ auto* stream = new RtpStreamSend(&testRtpStreamListener, params, mid);
103
103
 
104
104
  // Receive all the packets (some of them not in order and/or duplicated).
105
105
  SendRtpPacket({ { stream, params.ssrc } }, packet1);
@@ -164,7 +164,7 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
164
164
  params.mimeType.type = RTC::RtpCodecMimeType::Type::VIDEO;
165
165
 
166
166
  std::string mid;
167
- RtpStreamSend* stream = new RtpStreamSend(&testRtpStreamListener, params, mid);
167
+ auto* stream = new RtpStreamSend(&testRtpStreamListener, params, mid);
168
168
 
169
169
  // Receive all the packets (some of them not in order and/or duplicated).
170
170
  SendRtpPacket({ { stream, params.ssrc } }, packet1);
@@ -217,7 +217,7 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
217
217
  params.mimeType.type = RTC::RtpCodecMimeType::Type::AUDIO;
218
218
 
219
219
  std::string mid;
220
- RtpStreamSend* stream = new RtpStreamSend(&testRtpStreamListener, params, mid);
220
+ auto* stream = new RtpStreamSend(&testRtpStreamListener, params, mid);
221
221
 
222
222
  // Receive all the packets (some of them not in order and/or duplicated).
223
223
  SendRtpPacket({ { stream, params.ssrc } }, packet1);
@@ -265,7 +265,7 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
265
265
  params1.mimeType.type = RTC::RtpCodecMimeType::Type::VIDEO;
266
266
 
267
267
  std::string mid;
268
- RtpStreamSend* stream1 = new RtpStreamSend(&testRtpStreamListener1, params1, mid);
268
+ auto* stream1 = new RtpStreamSend(&testRtpStreamListener1, params1, mid);
269
269
 
270
270
  RtpStream::Params params2;
271
271
 
@@ -274,7 +274,7 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
274
274
  params2.useNack = true;
275
275
  params2.mimeType.type = RTC::RtpCodecMimeType::Type::VIDEO;
276
276
 
277
- RtpStreamSend* stream2 = new RtpStreamSend(&testRtpStreamListener2, params2, mid);
277
+ auto* stream2 = new RtpStreamSend(&testRtpStreamListener2, params2, mid);
278
278
 
279
279
  // Receive all the packets in both streams.
280
280
  SendRtpPacket({ { stream1, params1.ssrc }, { stream2, params2.ssrc } }, packet1);
@@ -340,7 +340,7 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
340
340
  params1.mimeType.type = RTC::RtpCodecMimeType::Type::VIDEO;
341
341
 
342
342
  std::string mid;
343
- RtpStreamSend* stream = new RtpStreamSend(&testRtpStreamListener1, params1, mid);
343
+ auto* stream = new RtpStreamSend(&testRtpStreamListener1, params1, mid);
344
344
 
345
345
  // Receive all the packets.
346
346
  SendRtpPacket({ { stream, params1.ssrc } }, packet1);
@@ -392,7 +392,7 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
392
392
  params1.mimeType.type = RTC::RtpCodecMimeType::Type::VIDEO;
393
393
 
394
394
  std::string mid;
395
- RtpStreamSend* stream = new RtpStreamSend(&testRtpStreamListener1, params1, mid);
395
+ auto* stream = new RtpStreamSend(&testRtpStreamListener1, params1, mid);
396
396
 
397
397
  // Receive all the packets.
398
398
  SendRtpPacket({ { stream, params1.ssrc } }, packet1);
@@ -435,7 +435,7 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
435
435
  params.mimeType.type = RTC::RtpCodecMimeType::Type::VIDEO;
436
436
 
437
437
  std::string mid;
438
- RtpStreamSend* stream = new RtpStreamSend(&testRtpStreamListener, params, mid);
438
+ auto* stream = new RtpStreamSend(&testRtpStreamListener, params, mid);
439
439
 
440
440
  size_t iterations = 10000000;
441
441