Skip to content

Commit b5d8517

Browse files
jmillanibc
andauthored
VP8: do not forward RTP packets which payload contains a higher temporal layer than current one. (#1009)
Worker: VP8, do not send frames with temporal layer higher than the current one Fixes #989 --------- Co-authored-by: Iñaki Baz Castillo <ibc@aliax.net>
1 parent 4638d83 commit b5d8517

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### NEXT
44

5+
- `Worker`: Drop VP8 packets with a higher temporal layer than the current one ([PR #1009](https://github.com/versatica/mediasoup/pull/1009)).
6+
57
### 3.15.3
68

79
- Node: Expose `Index` interface in `types.indexTypes` or via `import { Index as MediasoupIndex } from 'mediasoup/lib/indexTypes'` ([PR #1485](https://github.com/versatica/mediasoup/pull/1485)).

worker/src/RTC/Codecs/VP8.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ namespace RTC
359359
// clang-format off
360360
if (
361361
this->payloadDescriptor->hasTlIndex &&
362-
this->payloadDescriptor->tlIndex > context->GetCurrentTemporalLayer()
362+
this->payloadDescriptor->tlIndex == context->GetTargetTemporalLayer()
363363
)
364364
// clang-format on
365365
{
@@ -375,6 +375,12 @@ namespace RTC
375375
context->SetCurrentTemporalLayer(context->GetTargetTemporalLayer());
376376
}
377377

378+
// Do not send tlIndex higher than current one.
379+
if (this->payloadDescriptor->tlIndex > context->GetCurrentTemporalLayer())
380+
{
381+
return false;
382+
}
383+
378384
// clang-format off
379385
if (
380386
this->payloadDescriptor->hasPictureId &&

worker/test/src/RTC/Codecs/TestVP8.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,68 @@ SCENARIO("process VP8 payload descriptor", "[codecs][vp8]")
322322
forwarded = ProcessPacket(context, 1, 0, 1);
323323
REQUIRE_FALSE(forwarded);
324324
}
325+
326+
SECTION("old packets with higher temporal layer than current are dropped")
327+
{
328+
RTC::Codecs::EncodingContext::Params params;
329+
params.spatialLayers = 0;
330+
params.temporalLayers = 2;
331+
Codecs::VP8::EncodingContext context(params);
332+
context.SyncRequired();
333+
334+
context.SetCurrentTemporalLayer(0);
335+
context.SetTargetTemporalLayer(0);
336+
337+
// Frame 1.
338+
auto forwarded = ProcessPacket(context, 1, 0, 0);
339+
REQUIRE(forwarded);
340+
REQUIRE(forwarded->pictureId == 1);
341+
REQUIRE(forwarded->tlIndex == 0);
342+
REQUIRE(forwarded->tl0PictureIndex == 1);
343+
344+
// Frame 2.
345+
forwarded = ProcessPacket(context, 2, 0, 0);
346+
REQUIRE(forwarded);
347+
REQUIRE(forwarded->pictureId == 2);
348+
REQUIRE(forwarded->tlIndex == 0);
349+
REQUIRE(forwarded->tl0PictureIndex == 1);
350+
351+
// Frame 3. Old packet with higher temporal layer than current.
352+
forwarded = ProcessPacket(context, 0, 0, 1);
353+
REQUIRE_FALSE(forwarded);
354+
REQUIRE(context.GetCurrentTemporalLayer() == 0);
355+
}
356+
357+
SECTION("packets with higher temporal layer than current are dropped")
358+
{
359+
RTC::Codecs::EncodingContext::Params params;
360+
params.spatialLayers = 0;
361+
params.temporalLayers = 2;
362+
Codecs::VP8::EncodingContext context(params);
363+
context.SyncRequired();
364+
365+
context.SetCurrentTemporalLayer(0);
366+
context.SetTargetTemporalLayer(0);
367+
368+
// Frame 1.
369+
auto forwarded = ProcessPacket(context, 1, 0, 0);
370+
REQUIRE(forwarded);
371+
REQUIRE(forwarded->pictureId == 1);
372+
REQUIRE(forwarded->tlIndex == 0);
373+
REQUIRE(forwarded->tl0PictureIndex == 1);
374+
375+
// Frame 2.
376+
forwarded = ProcessPacket(context, 2, 0, 0);
377+
REQUIRE(forwarded);
378+
REQUIRE(forwarded->pictureId == 2);
379+
REQUIRE(forwarded->tlIndex == 0);
380+
REQUIRE(forwarded->tl0PictureIndex == 1);
381+
382+
context.SetTargetTemporalLayer(2);
383+
384+
// Frame 3. Old packet with higher temporal layer than current.
385+
forwarded = ProcessPacket(context, 3, 0, 1);
386+
REQUIRE_FALSE(forwarded);
387+
REQUIRE(context.GetCurrentTemporalLayer() == 0);
388+
}
325389
}

0 commit comments

Comments
 (0)