mediasoup 3.19.1 → 3.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup",
3
- "version": "3.19.1",
3
+ "version": "3.19.2",
4
4
  "description": "Cutting Edge WebRTC Video Conferencing",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -100,12 +100,12 @@
100
100
  "tar": "^7.4.3"
101
101
  },
102
102
  "devDependencies": {
103
- "@eslint/js": "^9.34.0",
103
+ "@eslint/js": "^9.35.0",
104
104
  "@octokit/rest": "^22.0.0",
105
105
  "@types/debug": "^4.1.12",
106
106
  "@types/jest": "^30.0.0",
107
- "@types/node": "^24.3.0",
108
- "eslint": "^9.34.0",
107
+ "@types/node": "^24.3.1",
108
+ "eslint": "^9.35.0",
109
109
  "eslint-config-prettier": "^10.1.8",
110
110
  "eslint-plugin-jest": "^29.0.1",
111
111
  "eslint-plugin-prettier": "^5.5.4",
@@ -9,6 +9,7 @@
9
9
  #include "handles/TimerHandle.hpp"
10
10
  #include <list>
11
11
  #include <string>
12
+ #include <unordered_map>
12
13
 
13
14
  namespace RTC
14
15
  {
@@ -23,10 +24,6 @@ namespace RTC
23
24
  DISCONNECTED,
24
25
  };
25
26
 
26
- public:
27
- static IceState RoleFromFbs(FBS::WebRtcTransport::IceState state);
28
- static FBS::WebRtcTransport::IceState IceStateToFbs(IceState state);
29
-
30
27
  public:
31
28
  class Listener
32
29
  {
@@ -54,6 +51,13 @@ namespace RTC
54
51
  virtual void OnIceServerDisconnected(const RTC::IceServer* iceServer) = 0;
55
52
  };
56
53
 
54
+ public:
55
+ static const std::string& IceStateToString(IceState iceState);
56
+ static FBS::WebRtcTransport::IceState IceStateToFbs(IceState state);
57
+
58
+ private:
59
+ static std::unordered_map<IceState, std::string> iceStateToString;
60
+
57
61
  public:
58
62
  IceServer(
59
63
  Listener* listener,
@@ -63,6 +67,7 @@ namespace RTC
63
67
  ~IceServer() override;
64
68
 
65
69
  public:
70
+ void Dump(int indentation = 0) const;
66
71
  void ProcessStunPacket(RTC::StunPacket* packet, RTC::TransportTuple* tuple);
67
72
  const std::string& GetUsernameFragment() const
68
73
  {
@@ -138,7 +143,6 @@ namespace RTC
138
143
  std::list<RTC::TransportTuple> tuples;
139
144
  RTC::TransportTuple* selectedTuple{ nullptr };
140
145
  TimerHandle* consentCheckTimer{ nullptr };
141
- uint64_t lastConsentRequestReceivedAtMs{ 0u };
142
146
  bool isRemovingTuples{ false };
143
147
  };
144
148
  } // namespace RTC
@@ -55,7 +55,7 @@ namespace RTC
55
55
 
56
56
  flatbuffers::Offset<FBS::Transport::Tuple> FillBuffer(flatbuffers::FlatBufferBuilder& builder) const;
57
57
 
58
- void Dump() const;
58
+ void Dump(int indentation = 0) const;
59
59
 
60
60
  void StoreUdpRemoteAddress()
61
61
  {
@@ -15,37 +15,31 @@ namespace RTC
15
15
  static constexpr uint8_t ConsentCheckMinTimeoutSec{ 10u };
16
16
  static constexpr uint8_t ConsentCheckMaxTimeoutSec{ 60u };
17
17
 
18
- /* Class methods. */
19
- IceServer::IceState IceStateFromFbs(FBS::WebRtcTransport::IceState state)
20
- {
21
- switch (state)
22
- {
23
- case FBS::WebRtcTransport::IceState::NEW:
24
- {
25
- return IceServer::IceState::NEW;
26
- }
18
+ /* Class variables. */
27
19
 
28
- case FBS::WebRtcTransport::IceState::CONNECTED:
29
- {
30
- return IceServer::IceState::CONNECTED;
31
- }
20
+ // clang-format off
21
+ std::unordered_map<IceServer::IceState, std::string> IceServer::iceStateToString =
22
+ {
23
+ { IceServer::IceState::NEW, "new" },
24
+ { IceServer::IceState::CONNECTED, "connected" },
25
+ { IceServer::IceState::COMPLETED, "completed" },
26
+ { IceServer::IceState::DISCONNECTED, "disconnected" },
27
+ };
28
+ // clang-format on
32
29
 
33
- case FBS::WebRtcTransport::IceState::COMPLETED:
34
- {
35
- return IceServer::IceState::COMPLETED;
36
- }
30
+ /* Class methods. */
37
31
 
38
- case FBS::WebRtcTransport::IceState::DISCONNECTED:
39
- {
40
- return IceServer::IceState::DISCONNECTED;
41
- }
32
+ const std::string& IceServer::IceStateToString(IceState iceState)
33
+ {
34
+ MS_TRACE();
42
35
 
43
- NO_DEFAULT_GCC();
44
- }
36
+ return IceServer::iceStateToString.at(iceState);
45
37
  }
46
38
 
47
39
  FBS::WebRtcTransport::IceState IceServer::IceStateToFbs(IceServer::IceState state)
48
40
  {
41
+ MS_TRACE();
42
+
49
43
  switch (state)
50
44
  {
51
45
  case IceServer::IceState::NEW:
@@ -152,6 +146,27 @@ namespace RTC
152
146
  this->consentCheckTimer = nullptr;
153
147
  }
154
148
 
149
+ void IceServer::Dump(int indentation) const
150
+ {
151
+ MS_TRACE();
152
+
153
+ MS_DUMP_CLEAN(indentation, "<IceServer>");
154
+ MS_DUMP_CLEAN(indentation, " state: %s", IceServer::IceStateToString(this->state).c_str());
155
+ MS_DUMP_CLEAN(indentation, " tuples:");
156
+ for (const auto& tuple : this->tuples)
157
+ {
158
+ tuple.Dump(indentation + 2);
159
+ }
160
+ if (this->selectedTuple)
161
+ {
162
+ MS_DUMP_CLEAN(indentation, " selected tuple:");
163
+ this->selectedTuple->Dump(indentation + 2);
164
+ }
165
+ MS_DUMP_CLEAN(indentation, " consent timeout (ms): %" PRIu16, this->consentTimeoutMs);
166
+ MS_DUMP_CLEAN(indentation, " remote nomination: %" PRIu32, this->remoteNomination);
167
+ MS_DUMP_CLEAN(indentation, "</IceServer>");
168
+ }
169
+
155
170
  void IceServer::ProcessStunPacket(RTC::StunPacket* packet, RTC::TransportTuple* tuple)
156
171
  {
157
172
  MS_TRACE();
@@ -587,9 +602,10 @@ namespace RTC
587
602
  else
588
603
  {
589
604
  // Store the tuple.
590
- auto* storedTuple = AddTuple(tuple);
605
+ auto* storedTuple = AddTuple(tuple);
606
+ const auto isNewNomination = hasNomination && nomination > this->remoteNomination;
591
607
 
592
- if ((hasNomination && nomination > this->remoteNomination) || !hasNomination)
608
+ if (isNewNomination || !hasNomination)
593
609
  {
594
610
  MS_DEBUG_TAG(
595
611
  ice,
@@ -606,7 +622,7 @@ namespace RTC
606
622
  SetSelectedTuple(storedTuple);
607
623
 
608
624
  // Update nomination.
609
- if (hasNomination && nomination > this->remoteNomination)
625
+ if (isNewNomination)
610
626
  {
611
627
  this->remoteNomination = nomination;
612
628
  }
@@ -649,9 +665,10 @@ namespace RTC
649
665
  else
650
666
  {
651
667
  // Store the tuple.
652
- auto* storedTuple = AddTuple(tuple);
668
+ auto* storedTuple = AddTuple(tuple);
669
+ const auto isNewNomination = hasNomination && nomination > this->remoteNomination;
653
670
 
654
- if ((hasNomination && nomination > this->remoteNomination) || !hasNomination)
671
+ if (isNewNomination || !hasNomination)
655
672
  {
656
673
  MS_DEBUG_TAG(
657
674
  ice,
@@ -668,7 +685,7 @@ namespace RTC
668
685
  SetSelectedTuple(storedTuple);
669
686
 
670
687
  // Update nomination.
671
- if (hasNomination && nomination > this->remoteNomination)
688
+ if (isNewNomination)
672
689
  {
673
690
  this->remoteNomination = nomination;
674
691
  }
@@ -705,9 +722,10 @@ namespace RTC
705
722
  nomination);
706
723
 
707
724
  // Store the tuple.
708
- auto* storedTuple = AddTuple(tuple);
725
+ auto* storedTuple = AddTuple(tuple);
726
+ const auto isNewNomination = hasNomination && nomination > this->remoteNomination;
709
727
 
710
- if ((hasNomination && nomination > this->remoteNomination) || !hasNomination)
728
+ if (isNewNomination || !hasNomination)
711
729
  {
712
730
  // Update state.
713
731
  this->state = IceState::COMPLETED;
@@ -716,7 +734,7 @@ namespace RTC
716
734
  SetSelectedTuple(storedTuple);
717
735
 
718
736
  // Update nomination.
719
- if (hasNomination && nomination > this->remoteNomination)
737
+ if (isNewNomination)
720
738
  {
721
739
  this->remoteNomination = nomination;
722
740
  }
@@ -745,17 +763,18 @@ namespace RTC
745
763
  else
746
764
  {
747
765
  // Store the tuple.
748
- auto* storedTuple = AddTuple(tuple);
766
+ auto* storedTuple = AddTuple(tuple);
767
+ const auto isNewNomination = hasNomination && nomination > this->remoteNomination;
749
768
 
750
- // When in completed state, only update selected tuple if there is ICE
751
- // nomination.
752
- if (hasNomination && nomination > this->remoteNomination)
769
+ // When in completed state, update selected tuple if there is ICE
770
+ // nomination or useCandidate.
771
+ if (isNewNomination || hasUseCandidate)
753
772
  {
754
773
  // Mark it as selected tuple.
755
774
  SetSelectedTuple(storedTuple);
756
775
 
757
776
  // Update nomination.
758
- if (hasNomination && nomination > this->remoteNomination)
777
+ if (isNewNomination)
759
778
  {
760
779
  this->remoteNomination = nomination;
761
780
  }
@@ -90,11 +90,11 @@ namespace RTC
90
90
  protocol);
91
91
  }
92
92
 
93
- void TransportTuple::Dump() const
93
+ void TransportTuple::Dump(int indentation) const
94
94
  {
95
95
  MS_TRACE();
96
96
 
97
- MS_DUMP("<TransportTuple>");
97
+ MS_DUMP_CLEAN(indentation, "<TransportTuple>");
98
98
 
99
99
  int family;
100
100
  std::string ip;
@@ -102,32 +102,32 @@ namespace RTC
102
102
 
103
103
  Utils::IP::GetAddressInfo(GetLocalAddress(), family, ip, port);
104
104
 
105
- MS_DUMP(" localIp: %s", ip.c_str());
106
- MS_DUMP(" localPort: %" PRIu16, port);
105
+ MS_DUMP_CLEAN(indentation, " localIp: %s", ip.c_str());
106
+ MS_DUMP_CLEAN(indentation, " localPort: %" PRIu16, port);
107
107
 
108
108
  Utils::IP::GetAddressInfo(GetRemoteAddress(), family, ip, port);
109
109
 
110
- MS_DUMP(" remoteIp: %s", ip.c_str());
111
- MS_DUMP(" remotePort: %" PRIu16, port);
110
+ MS_DUMP_CLEAN(indentation, " remoteIp: %s", ip.c_str());
111
+ MS_DUMP_CLEAN(indentation, " remotePort: %" PRIu16, port);
112
112
 
113
113
  switch (GetProtocol())
114
114
  {
115
115
  case Protocol::UDP:
116
116
  {
117
- MS_DUMP(" protocol: udp");
117
+ MS_DUMP_CLEAN(indentation, " protocol: udp");
118
118
 
119
119
  break;
120
120
  }
121
121
 
122
122
  case Protocol::TCP:
123
123
  {
124
- MS_DUMP(" protocol: tcp");
124
+ MS_DUMP_CLEAN(indentation, " protocol: tcp");
125
125
 
126
126
  break;
127
127
  }
128
128
  }
129
129
 
130
- MS_DUMP("</TransportTuple>");
130
+ MS_DUMP_CLEAN(indentation, "</TransportTuple>");
131
131
  }
132
132
 
133
133
  void TransportTuple::GenerateHash()