mediasoup 3.16.2 → 3.16.3

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.16.2",
3
+ "version": "3.16.3",
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.29.0",
103
+ "@eslint/js": "^9.30.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.0.4",
108
- "eslint": "^9.29.0",
107
+ "@types/node": "^24.0.7",
108
+ "eslint": "^9.30.0",
109
109
  "eslint-config-prettier": "^10.1.5",
110
110
  "eslint-plugin-jest": "^29.0.1",
111
111
  "eslint-plugin-prettier": "^5.5.1",
@@ -20,7 +20,7 @@ namespace RTC
20
20
  void Reset();
21
21
 
22
22
  // Original packet.
23
- std::shared_ptr<RTC::RtpPacket> packet{ nullptr };
23
+ std::shared_ptr<RTC::RtpPacket> sharedPacket{ nullptr };
24
24
  // Payload descriptor encoder.
25
25
  std::unique_ptr<RTC::Codecs::PayloadDescriptor::Encoder> encoder{ nullptr };
26
26
  // Correct SSRC since original packet may not have the same.
@@ -265,10 +265,8 @@ namespace RTC
265
265
 
266
266
  // Store the packet for the scenario in which this packet is part of the
267
267
  // key frame and it arrived before the first packet of the key frame.
268
- // TODO: Uncomment once this issue is fixed:
269
- // https://github.com/versatica/mediasoup/issues/1554
270
- // StorePacketInTargetLayerRetransmissionBuffer(
271
- // targetLayerRetransmissionBuffer, packet, sharedPacket);
268
+ StorePacketInTargetLayerRetransmissionBuffer(
269
+ targetLayerRetransmissionBuffer, packet, sharedPacket);
272
270
 
273
271
  return;
274
272
  }
@@ -409,12 +407,27 @@ namespace RTC
409
407
  {
410
408
  MS_DEBUG_DEV(
411
409
  "sending packet buffered in the target layer retransmission buffer [ssrc:%" PRIu32
412
- ", seq:%" PRIu16 ", ts:%" PRIu32 "]",
410
+ ", seq:%" PRIu16 ", ts:%" PRIu32
411
+ "] after sending first packet of the key frame [ssrc:%" PRIu32 ", seq:%" PRIu16
412
+ ", ts:%" PRIu32 "]",
413
413
  bufferedPacket->GetSsrc(),
414
414
  bufferedPacket->GetSequenceNumber(),
415
- bufferedPacket->GetTimestamp());
415
+ bufferedPacket->GetTimestamp(),
416
+ packet->GetSsrc(),
417
+ packet->GetSequenceNumber(),
418
+ packet->GetTimestamp());
416
419
 
417
420
  SendRtpPacket(bufferedPacket, bufferedSharedPacket);
421
+
422
+ // Be sure that the target layer retransmission buffer has not been
423
+ // emptied as a result of sending this packet. If so, exit the loop.
424
+ if (targetLayerRetransmissionBuffer.size() == 0)
425
+ {
426
+ MS_DEBUG_DEV(
427
+ "target layer retransmission buffer emptied while iterating it, exiting the loop");
428
+
429
+ break;
430
+ }
418
431
  }
419
432
  }
420
433
  }
@@ -30,7 +30,7 @@ namespace RTC
30
30
  }
31
31
 
32
32
  // Store original packet and some extra info into the item.
33
- item->packet = sharedPacket;
33
+ item->sharedPacket = sharedPacket;
34
34
  item->encoder = packet->GetPayloadEncoder();
35
35
  item->ssrc = packet->GetSsrc();
36
36
  item->sequenceNumber = packet->GetSequenceNumber();
@@ -589,7 +589,7 @@ namespace RTC
589
589
  {
590
590
  MS_TRACE();
591
591
 
592
- this->packet.reset();
592
+ this->sharedPacket.reset();
593
593
  this->ssrc = 0u;
594
594
  this->sequenceNumber = 0u;
595
595
  this->timestamp = 0u;
@@ -151,28 +151,76 @@ namespace RTC
151
151
  break;
152
152
  }
153
153
 
154
- // Note that this is an already RTX encoded packet if RTX is used
155
- // (FillRetransmissionContainer() did it).
156
- auto packet = item->packet;
154
+ auto* packet = item->sharedPacket.get();
155
+
156
+ // Keep the values of the original packet received by the Consumer.
157
+ auto origSsrc = packet->GetSsrc();
158
+ auto origSeq = packet->GetSequenceNumber();
159
+ auto origTimestamp = packet->GetTimestamp();
160
+ std::string origMid;
161
+
162
+ // Put correct info into the packet.
163
+ packet->SetSsrc(item->ssrc);
164
+ packet->SetSequenceNumber(item->sequenceNumber);
165
+ packet->SetTimestamp(item->timestamp);
166
+
167
+ if (item->encoder != nullptr)
168
+ {
169
+ packet->EncodePayload(item->encoder.get());
170
+ }
171
+
172
+ // Update MID RTP extension value.
173
+ if (!this->mid.empty())
174
+ {
175
+ packet->ReadMid(origMid);
176
+ packet->UpdateMid(this->mid);
177
+ }
178
+
179
+ // If we use RTX, encode it.
180
+ if (HasRtx())
181
+ {
182
+ // Increment RTX seq.
183
+ this->rtxSeq++;
184
+
185
+ packet->RtxEncode(this->params.rtxPayloadType, this->params.rtxSsrc, this->rtxSeq);
186
+ }
157
187
 
158
188
  // Retransmit the packet.
159
189
  static_cast<RTC::RtpStreamSend::Listener*>(this->listener)
160
- ->OnRtpStreamRetransmitRtpPacket(this, packet.get());
190
+ ->OnRtpStreamRetransmitRtpPacket(this, packet);
161
191
 
162
192
  // Mark the packet as retransmitted.
163
- RTC::RtpStream::PacketRetransmitted(packet.get());
193
+ RTC::RtpStream::PacketRetransmitted(packet);
164
194
 
165
195
  // Mark the packet as repaired (only if this is the first retransmission).
166
196
  if (item->sentTimes == 1)
167
197
  {
168
- RTC::RtpStream::PacketRepaired(packet.get());
198
+ RTC::RtpStream::PacketRepaired(packet);
169
199
  }
170
200
 
201
+ // If we use RTX, restore it.
171
202
  if (HasRtx())
172
203
  {
173
204
  // Restore the packet.
174
205
  packet->RtxDecode(RtpStream::GetPayloadType(), item->ssrc);
175
206
  }
207
+
208
+ // Restore MID.
209
+ if (!this->mid.empty())
210
+ {
211
+ packet->UpdateMid(origMid);
212
+ }
213
+
214
+ // Restore payload.
215
+ if (item->encoder != nullptr)
216
+ {
217
+ packet->RestorePayload();
218
+ }
219
+
220
+ // Restore RTP header fields.
221
+ packet->SetSsrc(origSsrc);
222
+ packet->SetSequenceNumber(origSeq);
223
+ packet->SetTimestamp(origTimestamp);
176
224
  }
177
225
  }
178
226
 
@@ -437,29 +485,6 @@ namespace RTC
437
485
  if (requested)
438
486
  {
439
487
  auto* item = this->retransmissionBuffer->Get(currentSeq);
440
- std::shared_ptr<RTC::RtpPacket> packet{ nullptr };
441
-
442
- // Calculate the elapsed time between the max timestamp seen and the
443
- // requested packet's timestamp (in ms).
444
- if (item)
445
- {
446
- packet = item->packet;
447
- // Put correct info into the packet.
448
- packet->SetSsrc(item->ssrc);
449
- packet->SetSequenceNumber(item->sequenceNumber);
450
- packet->SetTimestamp(item->timestamp);
451
-
452
- if (item->encoder != nullptr)
453
- {
454
- packet->EncodePayload(item->encoder.get());
455
- }
456
-
457
- // Update MID RTP extension value.
458
- if (!this->mid.empty())
459
- {
460
- packet->UpdateMid(mid);
461
- }
462
- }
463
488
 
464
489
  // Packet not found.
465
490
  if (!item)
@@ -478,21 +503,12 @@ namespace RTC
478
503
  rtx,
479
504
  "ignoring retransmission for a packet already resent in the last RTT ms "
480
505
  "[seq:%" PRIu16 ", rtt:%" PRIu16 "]",
481
- packet->GetSequenceNumber(),
506
+ item->sequenceNumber,
482
507
  rtt);
483
508
  }
484
509
  // Stored packet is valid for retransmission. Resend it.
485
510
  else
486
511
  {
487
- // If we use RTX and the packet has not yet been resent, encode it now.
488
- if (HasRtx())
489
- {
490
- // Increment RTX seq.
491
- ++this->rtxSeq;
492
-
493
- packet->RtxEncode(this->params.rtxPayloadType, this->params.rtxSsrc, this->rtxSeq);
494
- }
495
-
496
512
  // Save when this packet was resent.
497
513
  item->resentAtMs = nowMs;
498
514
 
@@ -513,12 +529,12 @@ namespace RTC
513
529
 
514
530
  requested = (bitmask & 1) != 0;
515
531
  bitmask >>= 1;
516
- ++currentSeq;
532
+ currentSeq++;
517
533
 
518
534
  if (!isFirstPacket)
519
535
  {
520
536
  sentBitmask |= (sent ? 1 : 0) << bitmaskCounter;
521
- ++bitmaskCounter;
537
+ bitmaskCounter++;
522
538
  }
523
539
  else
524
540
  {
@@ -347,9 +347,7 @@ namespace RTC
347
347
 
348
348
  // Store the packet for the scenario in which this packet is part of the
349
349
  // key frame and it arrived before the first packet of the key frame.
350
- // TODO: Uncomment once this issue is fixed:
351
- // https://github.com/versatica/mediasoup/issues/1554
352
- // StorePacketInTargetLayerRetransmissionBuffer(packet, sharedPacket);
350
+ StorePacketInTargetLayerRetransmissionBuffer(packet, sharedPacket);
353
351
 
354
352
  return;
355
353
  }
@@ -508,12 +506,27 @@ namespace RTC
508
506
  {
509
507
  MS_DEBUG_DEV(
510
508
  "sending packet buffered in the target layer retransmission buffer [ssrc:%" PRIu32
511
- ", seq:%" PRIu16 ", ts:%" PRIu32 "]",
509
+ ", seq:%" PRIu16 ", ts:%" PRIu32
510
+ "] after sending first packet of the key frame [ssrc:%" PRIu32 ", seq:%" PRIu16
511
+ ", ts:%" PRIu32 "]",
512
512
  bufferedPacket->GetSsrc(),
513
513
  bufferedPacket->GetSequenceNumber(),
514
- bufferedPacket->GetTimestamp());
514
+ bufferedPacket->GetTimestamp(),
515
+ packet->GetSsrc(),
516
+ packet->GetSequenceNumber(),
517
+ packet->GetTimestamp());
515
518
 
516
519
  SendRtpPacket(bufferedPacket, bufferedSharedPacket);
520
+
521
+ // Be sure that the target layer retransmission buffer has not been
522
+ // emptied as a result of sending this packet. If so, exit the loop.
523
+ if (this->targetLayerRetransmissionBuffer.size() == 0)
524
+ {
525
+ MS_DEBUG_DEV(
526
+ "target layer retransmission buffer emptied while iterating it, exiting the loop");
527
+
528
+ break;
529
+ }
517
530
  }
518
531
  }
519
532
  }
@@ -811,9 +811,7 @@ namespace RTC
811
811
 
812
812
  // Store the packet for the scenario in which this packet is part of the
813
813
  // key frame and it arrived before the first packet of the key frame.
814
- // TODO: Uncomment once this issue is fixed:
815
- // https://github.com/versatica/mediasoup/issues/1554
816
- // StorePacketInTargetLayerRetransmissionBuffer(packet, sharedPacket);
814
+ StorePacketInTargetLayerRetransmissionBuffer(packet, sharedPacket);
817
815
 
818
816
  return;
819
817
  }
@@ -1205,12 +1203,27 @@ namespace RTC
1205
1203
  {
1206
1204
  MS_DEBUG_DEV(
1207
1205
  "sending packet buffered in the target layer retransmission buffer [ssrc:%" PRIu32
1208
- ", seq:%" PRIu16 ", ts:%" PRIu32 "]",
1206
+ ", seq:%" PRIu16 ", ts:%" PRIu32
1207
+ "] after sending first packet of the key frame [ssrc:%" PRIu32 ", seq:%" PRIu16
1208
+ ", ts:%" PRIu32 "]",
1209
1209
  bufferedPacket->GetSsrc(),
1210
1210
  bufferedPacket->GetSequenceNumber(),
1211
- bufferedPacket->GetTimestamp());
1211
+ bufferedPacket->GetTimestamp(),
1212
+ packet->GetSsrc(),
1213
+ packet->GetSequenceNumber(),
1214
+ packet->GetTimestamp());
1212
1215
 
1213
1216
  SendRtpPacket(bufferedPacket, bufferedSharedPacket);
1217
+
1218
+ // Be sure that the target layer retransmission buffer has not been
1219
+ // emptied as a result of sending this packet. If so, exit the loop.
1220
+ if (this->targetLayerRetransmissionBuffer.size() == 0)
1221
+ {
1222
+ MS_DEBUG_DEV(
1223
+ "target layer retransmission buffer emptied while iterating it, exiting the loop");
1224
+
1225
+ break;
1226
+ }
1214
1227
  }
1215
1228
  }
1216
1229
  }
@@ -685,9 +685,7 @@ namespace RTC
685
685
 
686
686
  // Store the packet for the scenario in which this packet is part of the
687
687
  // key frame and it arrived before the first packet of the key frame.
688
- // TODO: Uncomment once this issue is fixed:
689
- // https://github.com/versatica/mediasoup/issues/1554
690
- // StorePacketInTargetLayerRetransmissionBuffer(packet, sharedPacket);
688
+ StorePacketInTargetLayerRetransmissionBuffer(packet, sharedPacket);
691
689
 
692
690
  return;
693
691
  }
@@ -865,12 +863,27 @@ namespace RTC
865
863
  {
866
864
  MS_DEBUG_DEV(
867
865
  "sending packet buffered in the target layer retransmission buffer [ssrc:%" PRIu32
868
- ", seq:%" PRIu16 ", ts:%" PRIu32 "]",
866
+ ", seq:%" PRIu16 ", ts:%" PRIu32
867
+ "] after sending first packet of the key frame [ssrc:%" PRIu32 ", seq:%" PRIu16
868
+ ", ts:%" PRIu32 "]",
869
869
  bufferedPacket->GetSsrc(),
870
870
  bufferedPacket->GetSequenceNumber(),
871
- bufferedPacket->GetTimestamp());
871
+ bufferedPacket->GetTimestamp(),
872
+ packet->GetSsrc(),
873
+ packet->GetSequenceNumber(),
874
+ packet->GetTimestamp());
872
875
 
873
876
  SendRtpPacket(bufferedPacket, bufferedSharedPacket);
877
+
878
+ // Be sure that the target layer retransmission buffer has not been
879
+ // emptied as a result of sending this packet. If so, exit the loop.
880
+ if (this->targetLayerRetransmissionBuffer.size() == 0)
881
+ {
882
+ MS_DEBUG_DEV(
883
+ "target layer retransmission buffer emptied while iterating it, exiting the loop");
884
+
885
+ break;
886
+ }
874
887
  }
875
888
  }
876
889
  }