From d812bb0ab415f1d30ddf4d69251aed57e247c69b Mon Sep 17 00:00:00 2001 From: Alex Andres Date: Tue, 10 Nov 2026 23:26:55 +0100 Subject: [PATCH] feat: check camera, microphone and network before a call WebRtc.checkCall measures whether a video track delivers frames that are not all black, whether an audio track delivers audio that is neither silent nor clipped, and whether a connection to a real test peer comes up, and names the problems it finds. --- docs/guide/client-api-design.md | 70 ++ docs/guide/client-api.md | 63 ++ .../dev/onvoid/webrtc/client/CallCheck.java | 191 ++++++ .../onvoid/webrtc/client/CallCheckResult.java | 386 +++++++++++ .../dev/onvoid/webrtc/client/CallChecker.java | 614 ++++++++++++++++++ .../onvoid/webrtc/client/LocalAudioImpl.java | 47 ++ .../java/dev/onvoid/webrtc/client/WebRtc.java | 27 + .../onvoid/webrtc/client/CallCheckTests.java | 377 +++++++++++ .../dev/onvoid/webrtc/client/ManualTimer.java | 28 + 9 files changed, 1803 insertions(+) create mode 100644 webrtc/src/main/java/dev/onvoid/webrtc/client/CallCheck.java create mode 100644 webrtc/src/main/java/dev/onvoid/webrtc/client/CallCheckResult.java create mode 100644 webrtc/src/main/java/dev/onvoid/webrtc/client/CallChecker.java create mode 100644 webrtc/src/test/java/dev/onvoid/webrtc/client/CallCheckTests.java diff --git a/docs/guide/client-api-design.md b/docs/guide/client-api-design.md index 6104d042e..9ca3936a7 100644 --- a/docs/guide/client-api-design.md +++ b/docs/guide/client-api-design.md @@ -219,6 +219,7 @@ public final class WebRtc implements AutoCloseable { public List peers(); // snapshot of the open peers public AudioMode audioMode(); public LoadStats loadStats(); // how much work waits and runs, cheap enough to read every second + public CompletableFuture checkCall(CallCheck check); // camera, microphone and network before a call public CompletableFuture closeAsync(); @Override @@ -858,6 +859,75 @@ public enum QualityCondition { - `diagnosticReport()` can go into a support ticket as it is. It leaves out raw stats, ids, addresses, ports, URLs, credentials, SDP, certificates and codec parameters. +### `CallCheck`, before a call + +A self-test for "am I ready for the call?": the camera delivers frames, the microphone audio that is +neither silent nor clipped, and a connection to a test peer comes up. + +```java +public final class CallCheck { + + public static Builder builder(); + + public static final class Builder { + public Builder video(LocalVideo track); // frames arrive, not all black + public Builder audio(LocalAudio track); // audio arrives, not silent, not clipped + public Builder network(PeerOptions options); // a connection to a test peer comes up + public Builder duration(Duration duration); // how long to measure, default 3 s + public Builder timeout(Duration timeout); // how long to wait for the first sample, default 10 s + public CallCheck build(); + } +} + +public final class CallCheckResult { + + public enum Problem { NO_VIDEO, DARK_VIDEO, NO_AUDIO, SILENT_AUDIO, CLIPPED_AUDIO, NO_CONNECTION; + public String reason(); + } + + public boolean isReady(); // no problem found, not a guarantee + public Set problems(); + public Video video(); // null for a part not checked + public Audio audio(); + public Network network(); + + public static final class Video { + public int frames(); + public double framesPerSecond(); + public int width(); + public int height(); + public double brightness(); // average luma of the brightest frame, 0 to 1 + } + + public static final class Audio { + public Duration received(); + public double peakLevel(); // linear, 0 to 1 + public double rmsLevel(); + public double clipping(); // share of samples at full scale + } + + public static final class Network { + public boolean isConnected(); + public Duration connectTime(); + public Duration roundTripTime(); + public String candidateType(); + public boolean isRelayed(); + public Throwable failure(); // TimeoutException, or why the peer failed + } +} +``` + +- The parts run at the same time, so a check takes as long as its slowest part. Each waits on the + runtime's timer for its first sample, then measures for the duration, which tests fire by hand + with a `ManualTimer`. +- Problems with reasons, as for `PeerDiagnostics`, rather than a score. +- Reachability is told by a connection to a real test peer, never derived from the configuration. + `relayOnly(true)` makes a connection prove the TURN servers. +- WebRTC records a microphone only while a send stream runs, and the client API does not start the + recording itself. So the check sends a microphone to a pair of peers of its own, whose sender drops + every encoded frame, so that the user does not hear themselves. The audio reaches the check + through a sink on the track, after processing. + ### `Whip` and `Whep` Sessions with a media server, over a peer with `Negotiation.MANUAL`. Their requests follow RFC 9725 diff --git a/docs/guide/client-api.md b/docs/guide/client-api.md index 795c35d1e..40925cbad 100644 --- a/docs/guide/client-api.md +++ b/docs/guide/client-api.md @@ -1019,6 +1019,69 @@ ICE credentials, SDP, certificates and codec parameters. Missing measurements become JSON null. The raw `report()` and its string representation are not sanitized diagnostic exports. +## Checking Before a Call + +Diagnostics watch a call that is under way. `checkCall` answers the question before it: am I ready +for the call? It checks that the camera delivers frames, that the microphone delivers audio that is +neither silent nor clipped, and that a connection to a test peer comes up, all at the same time: + +```java +LocalCamera camera = rtc.media().camera(); +LocalAudio microphone = rtc.media().microphone(); + +CallCheck check = CallCheck.builder() + .video(camera) + .audio(microphone) // ask the user to say something meanwhile + .network(PeerOptions.builder() + .iceServer("turn:turn.example.com", "user", "secret") + .relayOnly(true) // only a relayed connection counts + .signaling(testPeerSignaling) + .build()) + .build(); + +rtc.checkCall(check).thenAccept(result -> { + if (result.isReady()) { + System.out.println("Ready: " + result); + } + result.problems().forEach(problem -> System.out.println(problem.reason())); +}); +``` + +Every part is optional, but a check needs at least one. Each waits up to the check's `timeout` +(10 seconds by default) for the first frame, the first audio or the connection, then measures for +its `duration` (3 seconds by default). The future completes on an event thread of the runtime's +local media, so the rule against `join()` holds there. The tracks stay the application's: the check +neither closes nor mutes them, and the same tracks can go into the call once it is done. + +| Problem | Found when | +|---|---| +| `NO_VIDEO` | The video track delivered no frame within the timeout. | +| `DARK_VIDEO` | No frame had an average luma above 8% of white: a covered lens, a closed privacy shutter or no light. The brightest frame counts, since a camera's first frames are often dark while its exposure settles. A muted track sends black frames, so it is dark too. | +| `NO_AUDIO` | The audio track delivered no audio within the timeout. | +| `SILENT_AUDIO` | The audio never rose above -50 dBFS: a muted microphone, or nobody spoke. | +| `CLIPPED_AUDIO` | More than 0.1% of the samples were at full scale (99% of it or above): the input is too loud and distorts. | +| `NO_CONNECTION` | No connection to the test peer came up within the timeout. `network().failure()` tells why: a `TimeoutException`, or the failure of the peer. | + +Besides the problems, the result has the measurements behind them: frames, frame rate, resolution and +brightness of the video; how much audio arrived, with its peak and RMS level and the share of +clipped samples; and for the network the time it took to connect, the round trip time, the local +candidate type and whether the connection is relayed. `isReady()` means that no part found a +problem, not that the call is sure to work. + +Audio is measured as the track sends it, after audio processing. WebRTC records a microphone only +while it sends it, so for a microphone the check sends the track to a peer of its own, in the same +runtime, which drops every encoded frame before it goes out: nothing is played back, and the user +does not hear themselves. That peer, and the one of the network check, show among `rtc.peers()` +while the check runs and are closed before the result goes out. + +Whether the network lets a call through cannot be told from the local configuration, only from a +connection that is made. The network part therefore connects to a real test peer: one the +application runs for this, such as an echo bot behind its own signaling, or any other peer that +answers the offer. The check creates a peer with the given options, opens a data channel so that it +offers, reads the connection's statistics once it is up and closes the peer. With `relayOnly(true)` +the connection can only go through the TURN servers of the options, so a connection proves that they +work; without it, a direct connection may come up instead. + ## Closing You close what you created, and closing an owner closes what it owns: diff --git a/webrtc/src/main/java/dev/onvoid/webrtc/client/CallCheck.java b/webrtc/src/main/java/dev/onvoid/webrtc/client/CallCheck.java new file mode 100644 index 000000000..0c71c541e --- /dev/null +++ b/webrtc/src/main/java/dev/onvoid/webrtc/client/CallCheck.java @@ -0,0 +1,191 @@ +/* + * Copyright 2026 Alex Andres + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.onvoid.webrtc.client; + +import static java.util.Objects.requireNonNull; + +import java.time.Duration; + +import dev.onvoid.webrtc.internal.Timeouts; + +/** + * What {@link WebRtc#checkCall(CallCheck)} checks before a call: whether a + * video track delivers frames, whether an audio track delivers audio that is + * neither silent nor clipped, and whether a connection to a test peer comes + * up. Any of the three may be left out, but not all of them. + *
{@code
+ * LocalCamera camera = rtc.media().camera();
+ * LocalAudio microphone = rtc.media().microphone();
+ *
+ * CallCheck check = CallCheck.builder()
+ *         .video(camera)
+ *         .audio(microphone)
+ *         .network(PeerOptions.builder()
+ *                 .iceServer("turn:turn.example.com", "user", "secret")
+ *                 .relayOnly(true)
+ *                 .signaling(testPeerSignaling)
+ *                 .build())
+ *         .build();
+ *
+ * rtc.checkCall(check).thenAccept(result -> {
+ *     result.problems().forEach(problem -> System.out.println(problem.reason()));
+ * });
+ * }
+ * The tracks stay the application's: the check neither closes nor mutes them, + * so the same tracks can go into the call afterwards. + */ +public final class CallCheck { + + final LocalVideo video; + + final LocalAudio audio; + + final PeerOptions network; + + final Duration duration; + + final Duration timeout; + + + private CallCheck(Builder builder) { + this.video = builder.video; + this.audio = builder.audio; + this.network = builder.network; + this.duration = builder.duration; + this.timeout = builder.timeout; + } + + /** + * @return a builder of a check. + */ + public static Builder builder() { + return new Builder(); + } + + + + /** Builds a {@link CallCheck}. */ + public static final class Builder { + + private LocalVideo video; + + private LocalAudio audio; + + private PeerOptions network; + + private Duration duration = Duration.ofSeconds(3); + + private Duration timeout = Duration.ofSeconds(10); + + + private Builder() { + } + + /** + * Checks that the track delivers frames that are not all black, as + * from a covered lens or a closed privacy shutter. The frames are + * those a local preview of the track gets. + * + * @param track a camera, a screen or any other local video track. + * + * @return this builder. + */ + public Builder video(LocalVideo track) { + this.video = requireNonNull(track, "track"); + return this; + } + + /** + * Checks that the track delivers audio that is neither silent nor + * clipped, so the user should speak during the check. The audio is + * measured as the track sends it, after audio processing. + *

+ * WebRTC records a microphone only while it sends it, so for a + * {@link LocalMedia#microphone() microphone} the check sends the track + * to a peer of its own, in this runtime, which it closes again. That + * peer drops every encoded frame before it goes out, so nothing is + * played back and the user does not hear themselves. + * + * @param track a microphone or any other local audio track. + * + * @return this builder. + */ + public Builder audio(LocalAudio track) { + this.audio = requireNonNull(track, "track"); + return this; + } + + /** + * Checks that a connection to a test peer comes up: a peer the + * application runs for this, or any other that answers over the + * signaling of the options, such as an echo bot. Only a connection + * that is made tells that the network lets one through; the local + * configuration alone cannot. With {@link + * PeerOptions.Builder#relayOnly(boolean) relayOnly} set, a connection + * proves that the TURN servers of the options work. + *

+ * The check creates a peer with the options, opens a data channel, so + * that the peer offers, reads the statistics of the connection and + * closes the peer again. + * + * @param options the ICE servers and the signaling to the test peer. + * + * @return this builder. + */ + public Builder network(PeerOptions options) { + this.network = requireNonNull(options, "options"); + return this; + } + + /** + * @param duration how long frames and audio are measured, from the + * first frame or the first audio on; 3 seconds by + * default. + * + * @return this builder. + */ + public Builder duration(Duration duration) { + this.duration = Timeouts.requirePositive(duration, "duration"); + return this; + } + + /** + * @param timeout how long the check waits for the first frame, the + * first audio and the connection before it reports + * that there is none; 10 seconds by default. + * + * @return this builder. + */ + public Builder timeout(Duration timeout) { + this.timeout = Timeouts.requirePositive(timeout, "timeout"); + return this; + } + + /** + * @return the check. + * + * @throws IllegalStateException if nothing was given to check. + */ + public CallCheck build() { + if (video == null && audio == null && network == null) { + throw new IllegalStateException("A call check needs video, audio or a network to check"); + } + + return new CallCheck(this); + } + } +} diff --git a/webrtc/src/main/java/dev/onvoid/webrtc/client/CallCheckResult.java b/webrtc/src/main/java/dev/onvoid/webrtc/client/CallCheckResult.java new file mode 100644 index 000000000..7ee5e9ca0 --- /dev/null +++ b/webrtc/src/main/java/dev/onvoid/webrtc/client/CallCheckResult.java @@ -0,0 +1,386 @@ +/* + * Copyright 2026 Alex Andres + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.onvoid.webrtc.client; + +import java.time.Duration; +import java.util.Collections; +import java.util.EnumSet; +import java.util.Set; + +/** + * What a {@link CallCheck} found. It names the problems with their reason + * rather than a score, and the measurements behind them. A part that was not + * checked is null. + */ +public final class CallCheckResult { + + /** A problem a check found. */ + public enum Problem { + + /** The video track delivered no frame within the timeout. */ + NO_VIDEO("The video track delivered no frame."), + + /** Every frame was nearly black. */ + DARK_VIDEO("Every frame was nearly black: a covered lens, a closed privacy shutter or no light."), + + /** The audio track delivered no audio within the timeout. */ + NO_AUDIO("The audio track delivered no audio."), + + /** The audio never rose above -50 dBFS. */ + SILENT_AUDIO("The audio stayed below -50 dBFS: a muted microphone, or nobody spoke during the check."), + + /** More than 0.1% of the samples were at full scale. */ + CLIPPED_AUDIO("More than 0.1% of the samples were at full scale: the input is too loud and distorts."), + + /** No connection to the test peer came up within the timeout. */ + NO_CONNECTION("No connection to the test peer came up."); + + private final String reason; + + + Problem(String reason) { + this.reason = reason; + } + + /** + * @return what the problem means, in a sentence. + */ + public String reason() { + return reason; + } + } + + private final Video video; + + private final Audio audio; + + private final Network network; + + private final Set problems; + + + CallCheckResult(Video video, Audio audio, Network network) { + this.video = video; + this.audio = audio; + this.network = network; + + Set found = EnumSet.noneOf(Problem.class); + + if (video != null) { + video.addProblems(found); + } + if (audio != null) { + audio.addProblems(found); + } + if (network != null && !network.isConnected()) { + found.add(Problem.NO_CONNECTION); + } + + this.problems = Collections.unmodifiableSet(found); + } + + /** + * @return true when no check found a problem. That is not a guarantee + * that the call will work, only that nothing checked stands in its way. + */ + public boolean isReady() { + return problems.isEmpty(); + } + + /** + * @return the problems found; empty when there is none. + */ + public Set problems() { + return problems; + } + + /** + * @return the measurements of the video track, or null when it was not + * checked. + */ + public Video video() { + return video; + } + + /** + * @return the measurements of the audio track, or null when it was not + * checked. + */ + public Audio audio() { + return audio; + } + + /** + * @return the connection to the test peer, or null when it was not + * checked. + */ + public Network network() { + return network; + } + + @Override + public String toString() { + return (isReady() ? "READY" : "NOT READY " + problems) + + (video != null ? " " + video : "") + + (audio != null ? " " + audio : "") + + (network != null ? " " + network : ""); + } + + + + /** The frames a video track delivered. */ + public static final class Video { + + /** The brightness below which a frame counts as nearly black. */ + static final double DARK = 0.08; + + private final int frames; + + private final double framesPerSecond; + + private final int width; + + private final int height; + + private final double brightness; + + + Video(int frames, double framesPerSecond, int width, int height, double brightness) { + this.frames = frames; + this.framesPerSecond = framesPerSecond; + this.width = width; + this.height = height; + this.brightness = brightness; + } + + /** + * @return the frames measured. + */ + public int frames() { + return frames; + } + + /** + * @return the rate at which the frames arrived; 0 with fewer than two. + */ + public double framesPerSecond() { + return framesPerSecond; + } + + /** + * @return the width of the last frame; 0 without one. + */ + public int width() { + return width; + } + + /** + * @return the height of the last frame; 0 without one. + */ + public int height() { + return height; + } + + /** + * @return the average luma of the brightest frame measured, from 0 + * (black) to 1 (white); 0 without a frame. A camera's first frames are + * often dark while its exposure settles, so the brightest one counts. + */ + public double brightness() { + return brightness; + } + + void addProblems(Set found) { + if (frames == 0) { + found.add(Problem.NO_VIDEO); + } + else if (brightness < DARK) { + found.add(Problem.DARK_VIDEO); + } + } + + @Override + public String toString() { + return String.format("video[%d frames, %.1f fps, %dx%d, brightness %.2f]", + frames, framesPerSecond, width, height, brightness); + } + } + + + + /** The audio an audio track delivered. */ + public static final class Audio { + + /** The peak level below which audio counts as silent, -50 dBFS. */ + static final double SILENT = 0.00316; + + /** The share of samples at full scale above which audio counts as clipped. */ + static final double CLIPPED = 0.001; + + private final Duration received; + + private final double peakLevel; + + private final double rmsLevel; + + private final double clipping; + + + Audio(Duration received, double peakLevel, double rmsLevel, double clipping) { + this.received = received; + this.peakLevel = peakLevel; + this.rmsLevel = rmsLevel; + this.clipping = clipping; + } + + /** + * @return how much audio was measured. + */ + public Duration received() { + return received; + } + + /** + * @return the highest sample, linear, from 0 to 1 (full scale). + */ + public double peakLevel() { + return peakLevel; + } + + /** + * @return the root mean square of the samples, linear, from 0 to 1. + */ + public double rmsLevel() { + return rmsLevel; + } + + /** + * @return the share of samples at full scale, at 99% of it or above, + * from 0 to 1. + */ + public double clipping() { + return clipping; + } + + void addProblems(Set found) { + if (received.isZero()) { + found.add(Problem.NO_AUDIO); + } + else if (peakLevel < SILENT) { + found.add(Problem.SILENT_AUDIO); + } + else if (clipping > CLIPPED) { + found.add(Problem.CLIPPED_AUDIO); + } + } + + @Override + public String toString() { + return String.format("audio[%d ms, peak %.3f, rms %.3f, clipping %.4f]", + received.toMillis(), peakLevel, rmsLevel, clipping); + } + } + + + + /** The connection to the test peer. */ + public static final class Network { + + private final Duration connectTime; + + private final Duration roundTripTime; + + private final String candidateType; + + private final boolean relayed; + + private final Throwable failure; + + + Network(Duration connectTime, Duration roundTripTime, String candidateType, boolean relayed, + Throwable failure) { + this.connectTime = connectTime; + this.roundTripTime = roundTripTime; + this.candidateType = candidateType; + this.relayed = relayed; + this.failure = failure; + } + + static Network failed(Throwable failure) { + return new Network(null, null, null, false, failure); + } + + /** + * @return true once the connection came up. + */ + public boolean isConnected() { + return connectTime != null; + } + + /** + * @return how long the connection took to come up, from the creation + * of the peer on; null when it did not. + */ + public Duration connectTime() { + return connectTime; + } + + /** + * @return the round-trip time of the connection, as ICE measured it; + * null when it is not known. + */ + public Duration roundTripTime() { + return roundTripTime; + } + + /** + * @return the type of the local candidate in use: host, srflx, prflx + * or relay; null when it is not known. + */ + public String candidateType() { + return candidateType; + } + + /** + * @return true when the connection goes through a TURN server, on + * either side. + */ + public boolean isRelayed() { + return relayed; + } + + /** + * @return why the connection did not come up: a {@link + * java.util.concurrent.TimeoutException} when the timeout passed, or + * the failure of the peer; null when it came up. + */ + public Throwable failure() { + return failure; + } + + @Override + public String toString() { + if (!isConnected()) { + return "network[not connected: " + failure + "]"; + } + + return "network[" + candidateType + (relayed ? ", relayed" : "") + ", connected in " + + connectTime.toMillis() + " ms" + + (roundTripTime != null ? ", rtt " + roundTripTime.toMillis() + " ms" : "") + "]"; + } + } +} diff --git a/webrtc/src/main/java/dev/onvoid/webrtc/client/CallChecker.java b/webrtc/src/main/java/dev/onvoid/webrtc/client/CallChecker.java new file mode 100644 index 000000000..73e45affd --- /dev/null +++ b/webrtc/src/main/java/dev/onvoid/webrtc/client/CallChecker.java @@ -0,0 +1,614 @@ +/* + * Copyright 2026 Alex Andres + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.onvoid.webrtc.client; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.function.Consumer; + +import dev.onvoid.webrtc.RTCEncodedFrame; +import dev.onvoid.webrtc.client.CallCheckResult.Audio; +import dev.onvoid.webrtc.client.CallCheckResult.Network; +import dev.onvoid.webrtc.client.CallCheckResult.Video; +import dev.onvoid.webrtc.internal.Timeouts; +import dev.onvoid.webrtc.media.audio.AudioTrackSink; +import dev.onvoid.webrtc.media.video.I420Buffer; +import dev.onvoid.webrtc.media.video.VideoFrame; +import dev.onvoid.webrtc.media.video.VideoFrameBuffer; + +/** + * Runs a {@link CallCheck}. Each part waits on the runtime's timer for its + * first sample, then measures for the duration of the check. Frames are + * measured on the thread of a preview subscription, audio on the thread that + * delivers it, where nothing waits for more than the few field updates under + * a part's lock. The peers the check creates are closed before its result + * goes out. + */ +final class CallChecker { + + /** A 16-bit sample at 99% of full scale or above counts as clipped. */ + private static final int CLIPPED_SAMPLE = 32440; + + private static final boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; + + private final WebRtc rtc; + + private final CallCheck check; + + /** The peers the check created. */ + private final List peers = new ArrayList<>(); + + + private CallChecker(WebRtc rtc, CallCheck check) { + this.rtc = rtc; + this.check = check; + } + + /** + * Starts the check. + * + * @return a future that completes with the result once every part is + * done and the check's peers are closed, or fails when the runtime closes + * first. + * + * @throws ConfigurationException if WebRTC refuses the network options. + * @throws PeerClosedException if the runtime is closed. + */ + static CompletableFuture start(WebRtc rtc, CallCheck check) { + LocalVideoImpl video = check.video != null ? checkTrack(rtc, check.video, LocalVideoImpl.class) : null; + LocalAudioImpl audio = check.audio != null ? checkTrack(rtc, check.audio, LocalAudioImpl.class) : null; + + return new CallChecker(rtc, check).start(video, audio); + } + + private CompletableFuture start(LocalVideoImpl videoTrack, LocalAudioImpl audioTrack) { + CompletableFuture network = CompletableFuture.completedFuture(null); + CompletableFuture