mediasoup 3.21.1 → 3.21.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### NEXT
4
4
 
5
+ ### 3.21.2
6
+
7
+ - Worker: Fix crash when an SCTP `DataConsumer` is closed and triggers buffered amount low event ([PR #1858](https://github.com/versatica/mediasoup/pull/1858)).
8
+
5
9
  ### 3.21.1
6
10
 
7
11
  - Worker: Enable SVC for VP8 and H264 ([PR #1851](https://github.com/versatica/mediasoup/pull/1851)).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup",
3
- "version": "3.21.1",
3
+ "version": "3.21.2",
4
4
  "description": "Cutting Edge WebRTC Video Conferencing",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -129,14 +129,14 @@
129
129
  "globals": "^17.7.0",
130
130
  "ini": "^7.0.0",
131
131
  "jest": "^30.4.2",
132
- "knip": "^6.26.0",
132
+ "knip": "^6.27.0",
133
133
  "marked": "^18.0.6",
134
134
  "open-cli": "^9.0.0",
135
135
  "pick-port": "^2.2.1",
136
136
  "prettier": "^3.9.5",
137
137
  "ts-jest": "^29.4.11",
138
138
  "typescript": "^6.0.3",
139
- "typescript-eslint": "^8.63.0",
139
+ "typescript-eslint": "^8.64.0",
140
140
  "werift-sctp": "^0.0.11"
141
141
  }
142
142
  }
@@ -210,7 +210,7 @@ namespace RTC
210
210
  const std::string& dataProducerId, const std::string& method) const final;
211
211
  virtual RTC::DataConsumer* AssertAndGetDataConsumerById(
212
212
  const std::string& dataConsumerId, const std::string& method) const final;
213
- virtual RTC::DataConsumer* AssertAndGetSctpDataConsumerByStreamId(uint16_t streamId) const final;
213
+ virtual RTC::DataConsumer* GetSctpDataConsumerByStreamId(uint16_t streamId) const final;
214
214
  virtual void CheckNoProducer(const std::string& producerId, const std::string& method) const final;
215
215
  virtual void CheckNoConsumer(const std::string& consumerId, const std::string& method) const final;
216
216
  virtual void CheckNoDataProducer(
@@ -446,7 +446,7 @@ namespace RTC
446
446
  {
447
447
  MS_TRACE();
448
448
 
449
- auto it = this->mapTransports.find(transportId);
449
+ const auto it = this->mapTransports.find(transportId);
450
450
 
451
451
  if (this->mapTransports.find(transportId) == this->mapTransports.end())
452
452
  {
@@ -461,7 +461,7 @@ namespace RTC
461
461
  {
462
462
  MS_TRACE();
463
463
 
464
- auto it = this->mapRtpObservers.find(rtpObserverId);
464
+ const auto it = this->mapRtpObservers.find(rtpObserverId);
465
465
 
466
466
  if (this->mapRtpObservers.find(rtpObserverId) == this->mapRtpObservers.end())
467
467
  {
@@ -566,7 +566,7 @@ namespace RTC
566
566
  consumer->ProducerPaused();
567
567
  }
568
568
 
569
- auto it = this->mapProducerRtpObservers.find(producer);
569
+ const auto it = this->mapProducerRtpObservers.find(producer);
570
570
 
571
571
  if (it != this->mapProducerRtpObservers.end())
572
572
  {
@@ -590,7 +590,7 @@ namespace RTC
590
590
  consumer->ProducerResumed();
591
591
  }
592
592
 
593
- auto it = this->mapProducerRtpObservers.find(producer);
593
+ const auto it = this->mapProducerRtpObservers.find(producer);
594
594
 
595
595
  if (it != this->mapProducerRtpObservers.end())
596
596
  {
@@ -688,7 +688,7 @@ namespace RTC
688
688
  }
689
689
  }
690
690
 
691
- auto it = this->mapProducerRtpObservers.find(producer);
691
+ const auto it = this->mapProducerRtpObservers.find(producer);
692
692
 
693
693
  if (it != this->mapProducerRtpObservers.end())
694
694
  {
@@ -1076,7 +1076,7 @@ namespace RTC
1076
1076
  RTC::Producer* Router::RtpObserverGetProducer(
1077
1077
  RTC::RtpObserver* /* rtpObserver */, const std::string& id)
1078
1078
  {
1079
- auto it = this->mapProducers.find(id);
1079
+ const auto it = this->mapProducers.find(id);
1080
1080
 
1081
1081
  if (it == this->mapProducers.end())
1082
1082
  {
@@ -1401,6 +1401,10 @@ namespace RTC
1401
1401
 
1402
1402
  if (this->sctpAssociation)
1403
1403
  {
1404
+ // NOTE: This must be called after removing data consumers from the maps,
1405
+ // otherwise if `OnAssociationStreamBufferedAmountLow()` was triggered it
1406
+ // would end up emitting an event associated to an already closed data
1407
+ // consumer.
1404
1408
  this->sctpAssociation->ResetStreams(
1405
1409
  std::array<uint16_t, 1>{ dataConsumer->GetSctpStreamParameters().streamId });
1406
1410
  }
@@ -1764,7 +1768,7 @@ namespace RTC
1764
1768
  {
1765
1769
  MS_TRACE();
1766
1770
 
1767
- auto it = this->mapProducers.find(producerId);
1771
+ const auto it = this->mapProducers.find(producerId);
1768
1772
 
1769
1773
  if (it == this->mapProducers.end())
1770
1774
  {
@@ -1779,7 +1783,7 @@ namespace RTC
1779
1783
  {
1780
1784
  MS_TRACE();
1781
1785
 
1782
- auto it = this->mapConsumers.find(consumerId);
1786
+ const auto it = this->mapConsumers.find(consumerId);
1783
1787
 
1784
1788
  if (it == this->mapConsumers.end())
1785
1789
  {
@@ -1793,7 +1797,7 @@ namespace RTC
1793
1797
  {
1794
1798
  MS_TRACE();
1795
1799
 
1796
- auto mapSsrcConsumerIt = this->mapSsrcConsumer.find(ssrc);
1800
+ const auto mapSsrcConsumerIt = this->mapSsrcConsumer.find(ssrc);
1797
1801
 
1798
1802
  if (mapSsrcConsumerIt == this->mapSsrcConsumer.end())
1799
1803
  {
@@ -1809,7 +1813,7 @@ namespace RTC
1809
1813
  {
1810
1814
  MS_TRACE();
1811
1815
 
1812
- auto mapRtxSsrcConsumerIt = this->mapRtxSsrcConsumer.find(ssrc);
1816
+ const auto mapRtxSsrcConsumerIt = this->mapRtxSsrcConsumer.find(ssrc);
1813
1817
 
1814
1818
  if (mapRtxSsrcConsumerIt == this->mapRtxSsrcConsumer.end())
1815
1819
  {
@@ -1826,7 +1830,7 @@ namespace RTC
1826
1830
  {
1827
1831
  MS_TRACE();
1828
1832
 
1829
- auto it = this->mapDataProducers.find(dataProducerId);
1833
+ const auto it = this->mapDataProducers.find(dataProducerId);
1830
1834
 
1831
1835
  if (it == this->mapDataProducers.end())
1832
1836
  {
@@ -1841,7 +1845,7 @@ namespace RTC
1841
1845
  {
1842
1846
  MS_TRACE();
1843
1847
 
1844
- auto it = this->mapDataConsumers.find(dataConsumerId);
1848
+ const auto it = this->mapDataConsumers.find(dataConsumerId);
1845
1849
 
1846
1850
  if (it == this->mapDataConsumers.end())
1847
1851
  {
@@ -1851,15 +1855,15 @@ namespace RTC
1851
1855
  return it->second;
1852
1856
  }
1853
1857
 
1854
- RTC::DataConsumer* Transport::AssertAndGetSctpDataConsumerByStreamId(uint16_t streamId) const
1858
+ RTC::DataConsumer* Transport::GetSctpDataConsumerByStreamId(uint16_t streamId) const
1855
1859
  {
1856
1860
  MS_TRACE();
1857
1861
 
1858
- auto it = this->mapSctpStreamIdDataConsumers.find(streamId);
1862
+ const auto it = this->mapSctpStreamIdDataConsumers.find(streamId);
1859
1863
 
1860
1864
  if (it == this->mapSctpStreamIdDataConsumers.end())
1861
1865
  {
1862
- MS_THROW_NOT_FOUND_ERROR("SCTP DataConsumer with streamId %" PRIu16 " not found", streamId);
1866
+ return nullptr;
1863
1867
  }
1864
1868
 
1865
1869
  return it->second;
@@ -2938,6 +2942,10 @@ namespace RTC
2938
2942
  this->mapSctpStreamIdDataConsumers.erase(dataConsumer->GetSctpStreamParameters().streamId);
2939
2943
  }
2940
2944
 
2945
+ // NOTE: This must be called after removing the data consumer from the maps,
2946
+ // otherwise if `OnAssociationStreamBufferedAmountLow()` was triggered it
2947
+ // would end up emitting an event associated to an already closed data
2948
+ // consumer.
2941
2949
  if (this->sctpAssociation)
2942
2950
  {
2943
2951
  this->sctpAssociation->ResetStreams(
@@ -3247,8 +3255,6 @@ namespace RTC
3247
3255
 
3248
3256
  if (!dataConsumersToClose.empty())
3249
3257
  {
3250
- this->sctpAssociation->ResetStreams(streamsToReset);
3251
-
3252
3258
  for (auto* dataConsumer : dataConsumersToClose)
3253
3259
  {
3254
3260
  // Remove it from the maps.
@@ -3271,6 +3277,12 @@ namespace RTC
3271
3277
  // Delete it.
3272
3278
  delete dataConsumer;
3273
3279
  }
3280
+
3281
+ // NOTE: This must be called after removing data consumers from the maps,
3282
+ // otherwise if `OnAssociationStreamBufferedAmountLow()` was triggered it
3283
+ // would end up emitting an event associated to an already closed data
3284
+ // consumer.
3285
+ this->sctpAssociation->ResetStreams(streamsToReset);
3274
3286
  }
3275
3287
  }
3276
3288
  }
@@ -3279,7 +3291,7 @@ namespace RTC
3279
3291
  {
3280
3292
  MS_TRACE();
3281
3293
 
3282
- const auto* dataConsumer = AssertAndGetSctpDataConsumerByStreamId(streamId);
3294
+ const auto* dataConsumer = GetSctpDataConsumerByStreamId(streamId);
3283
3295
 
3284
3296
  if (!dataConsumer)
3285
3297
  {
@@ -188,7 +188,7 @@ RTC::WebRtcServer* Worker::AssertAndGetWebRtcServerById(
188
188
  {
189
189
  MS_TRACE();
190
190
 
191
- auto it = this->mapWebRtcServers.find(webRtcServerId);
191
+ const auto it = this->mapWebRtcServers.find(webRtcServerId);
192
192
 
193
193
  if (it == this->mapWebRtcServers.end())
194
194
  {
@@ -202,7 +202,7 @@ RTC::Router* Worker::AssertAndGetRouterById(const std::string& routerId, const s
202
202
  {
203
203
  MS_TRACE();
204
204
 
205
- auto it = this->mapRouters.find(routerId);
205
+ const auto it = this->mapRouters.find(routerId);
206
206
 
207
207
  if (it == this->mapRouters.end())
208
208
  {