Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import dev.onvoid.webrtc.media.video.I420Buffer;
Expand Down Expand Up @@ -523,6 +524,10 @@ else if (width == 320 && frame.buffer.getHeight() == 240) {
@Test
void hardwareDecodesVp9FixedInterpolationFilter() throws Exception {
assumeVp9Platform();
// Without a VP9 hardware decoder, both calls would decode with libvpx,
// compare nothing and be skipped only at the end, after a call that
// needs every frame of the stream to reach the sink.
assumeVp9HardwareDecoder();

List<ByteBuffer> stream = readIvf("vp9-fixed-filter.ivf");

Expand Down Expand Up @@ -582,7 +587,14 @@ private byte[] lastVp9Frame(VideoDecoderFactory decoders, List<ByteBuffer> strea
call.awaitConnected();
call.startMedia();

assertTrue(received.await(TIMEOUT_SECONDS, TimeUnit.SECONDS), "too few frames received");
if (!received.await(TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
// Tells whether the frames were lost before or after decoding.
Map<String, Object> inbound = call.getInboundVideoStats();

fail("too few frames received: " + (stream.size() - received.getCount()) + " of " + stream.size()
+ (inbound == null ? "" : ", decoded " + inbound.get("framesDecoded") + ", dropped "
+ inbound.get("framesDropped") + ", key frames asked for " + inbound.get("pliCount")));
}

implementation = decoderImplementationOf(call);

Expand Down Expand Up @@ -903,6 +915,23 @@ private static boolean isHardware(String implementation) {
|| implementation.contains("NVDEC") || implementation.contains("VA-API");
}

/**
* Where a hardware decoder is required, the test fails without one for
* VP9; elsewhere it is skipped before it starts a call.
*/
private static void assumeVp9HardwareDecoder() {
boolean required = OS.contains("mac") ? HARDWARE_REQUIRED : HARDWARE_VP9_REQUIRED;
boolean available = new HardwareVideoDecoderFactory().getHardwareCodecs().stream()
.anyMatch(codec -> "VP9".equalsIgnoreCase(codec.getName()));

if (required) {
assertTrue(available, "no hardware VP9 decoder");
}
else {
assumeTrue(available, "no hardware VP9 decoder");
}
}

/**
* Where a hardware decoder is required, the test fails without one;
* elsewhere it is skipped.
Expand Down
Loading