Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions design/client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ low-level API stays as it is.

- Package `dev.onvoid.webrtc.client`, in the existing `webrtc-java` jar, exported by the
`webrtc.java` module.
- Java 8, like the rest of the module: no records, no sealed types, no `var`.
- Java 11, like the rest of the module: no records, no sealed types.
- Pure Java. Phase 1 needs no native or JNI changes and changes no existing signature.

## Decisions
Expand All @@ -20,7 +20,7 @@ These were open questions in the mockup. Each went with its recommendation.
|---|---|---|
| Where does it live? | A package in the existing jar, not a separate artifact. | Users get it without another dependency. It follows the core's releases. |
| Default perfect negotiation role? | Impolite by default. | Glare between two impolite peers fails with a `NegotiationException` that names the fix (make one side polite). Every example sets the role explicitly. |
| Plain `CompletableFuture` or an own type? | Plain `CompletableFuture`. | On Java 8, stages derived from a subclass are plain `CompletableFuture`s, so `BlockingCallException` only catches a `join()`/`get()` on the future the API returned. The exception message and the event thread names help with the rest. |
| Plain `CompletableFuture` or an own type? | Plain `CompletableFuture`. | The API returns a `ClientFuture` subclass behind the type, whose derived stages are `ClientFuture`s too, so `BlockingCallException` catches a `join()`/`get()` on them as well. The exception message and the event thread names help with the rest. |
| Does `Peer.close()` block? | No, never. | Safe in handlers and on UI threads. `closeAsync()` returns a future for callers who want to wait. `WebRtc.close()` is the one call that waits for everything. |
| A camera opened twice? | Shared when the options match, `MediaException` when they differ. | One capture per device. Most platforms can't open a device with two capabilities anyway. |
| Entry point name? | `WebRtc`. | `try (WebRtc rtc = WebRtc.create()) { ... }` |
Expand Down Expand Up @@ -750,8 +750,8 @@ How the threading model is built:
- Native observer completions are posted back to the control executor before anything is chained
on them, so no internal code ever runs on a WebRTC thread.
- Public futures are `ClientFuture`s completed on the event executor. `join()`/`get()` on an
unfinished one from any event thread throws `BlockingCallException`. On Java 9+ derived stages
refuse too, through `newIncompleteFuture`.
unfinished one from any event thread throws `BlockingCallException`. Derived stages refuse too,
through `newIncompleteFuture`.
- Frame and audio subscriptions each get a `SerialExecutor` over a frame pool, with the drop
policies described above.
- `CustomAudio` is cut into 10 ms chunks and pushed from the runtime's timer thread, every 10 ms.
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You don't have to install Chromium's `depot_tools`, Siso or GN: the build clones

| Tool | Notes |
| --------------------- | ----------------------------------------------------------------------------------------- |
| JDK 17 or newer | The libraries target Java 8, but the JavaFX module needs 11 and the examples need 17. |
| JDK 17 or newer | The libraries target Java 11, and the examples need 17. |
| Maven 3.6.3 or newer | |
| Git | Clones `depot_tools`, the WebRTC sources and the submodules. |
| CMake 3.13 or newer | Must be on the `PATH`. The Maven build does not download it. |
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ A future that is already done may be read anywhere, and any thread that is not a

Each call returns a future of its own, also of `closeAsync()`, `whenClosed()`, `whenConnected()` and `whenOpen()`. Cancelling one only stops waiting: the close goes on, and the futures of other callers, and of the runtime's own close, are not affected.

::: warning
On Java 8, only the futures the API returns refuse to be waited on. Futures derived from them with `thenApply` and the like do not, so waiting for one of those in a handler hangs that peer. From Java 9 on, the derived futures refuse too.
Futures derived from them with `thenApply` and the like refuse to be waited on as well.

A UI thread used as event executor is the same: waiting on it for a future of this API hangs the UI, since the future completes on it.
::: warning
A UI thread used as event executor does not refuse: waiting on it for a future of this API hangs the UI, since the future completes on it.
:::

## Sending Media
Expand Down
25 changes: 2 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,33 +75,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.16.0</version>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<release>9</release>
<!-- No excludes: compile everything to ensure module-info contains the right entries -->
</configuration>
</execution>
<execution>
<id>base-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<!-- Recompile everything for the target VM except the module-info.java -->
<excludes>
<exclude>module-info.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
<!-- Defaults for compiler and testCompile -->
<configuration>
<release>8</release><!-- compatibility expectations -->
<release>11</release><!-- compatibility expectations -->
<!-- Only required when haven't configured the maven-toolchains-plugin -->
<jdkToolchain>
<version>9</version>
<version>11</version>
</jdkToolchain>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
Expand Down
17 changes: 0 additions & 17 deletions webrtc-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<!-- Clear parent executions -->
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>17</release>
</configuration>
</execution>
<execution>
<id>base-compile</id>
<phase>none</phase>
</execution>
</executions>
<configuration>
<release>17</release>
<jdkToolchain>
Expand Down
29 changes: 0 additions & 29 deletions webrtc-javafx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,6 @@
<javafx.version>17.0.20</javafx.version>
</properties>

<build>
<plugins>
<!-- OpenJFX is built for Java 11, so this module cannot target the
Java 8 the rest of the library does. The module descriptor
compiles at Java 11 too, which makes the parent's second pass,
the one that recompiles the classes for Java 8 without the
descriptor, unnecessary. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<release>11</release>
</configuration>
</execution>
<execution>
<id>base-compile</id>
<phase>none</phase>
</execution>
</executions>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>dev.onvoid.webrtc</groupId>
Expand Down
10 changes: 5 additions & 5 deletions webrtc/src/main/java/dev/onvoid/webrtc/client/ClientFuture.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
* {@link #get()} refuse with a {@link BlockingCallException} instead of
* deadlocking. A future that is already done may be read anywhere.
* <p>
* On Java 9 and later the futures derived from this one, with {@code
* thenApply} and the like, are of this class too and refuse the same way.
* The futures derived from this one, with {@code thenApply} and the like, are
* of this class too and refuse the same way.
*
* @param <T> the result type.
*/
Expand Down Expand Up @@ -81,14 +81,14 @@ public T join() {
}

/**
* Makes the futures derived from this one, on Java 9 and later, refuse to
* be waited on from an event thread as well. Java 8 has no such method and
* never calls it.
* Makes the futures derived from this one refuse to be waited on from an
* event thread as well.
*
* @param <U> the result type of the derived future.
*
* @return a new incomplete future.
*/
@Override
public <U> CompletableFuture<U> newIncompleteFuture() {
return new ClientFuture<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void joinOnEventThreadRefused() throws Exception {

assertInstanceOf(BlockingCallException.class, await(refused));

// On Java 9 and later, so do the futures derived from them.
// So do the futures derived from them.
CompletableFuture<Throwable> derivedRefused = new CompletableFuture<>();
peers[1].onStateChange(state -> {
try {
Expand Down
Loading