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
2 changes: 1 addition & 1 deletion .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ runs:
PROFILES: ${{ inputs.profiles }}
SKIP_UPLOAD: ${{ inputs.skip-upload }}
run: >
mvn -B deploy -pl .,webrtc,webrtc-java-media -DskipTests
mvn -B deploy -pl .,webrtc,webrtc-java-media,webrtc-java-javafx -DskipTests
-Dmaven.repository.credentialScope=id
${PROFILES:+-P$PROFILES}
-Dnatives.dir="$PWD/natives"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ jobs:
echo '```'
ls -1 webrtc/target/*.jar webrtc/target/*.asc \
webrtc-java-media/target/*.jar webrtc-java-media/target/*.asc \
webrtc-java-javafx/target/*.jar webrtc-java-javafx/target/*.asc \
natives/*.asc 2>/dev/null || true
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
Expand All @@ -240,6 +241,9 @@ jobs:
webrtc-java-media/target/central-*/**
webrtc-java-media/target/*.jar
webrtc-java-media/target/*.asc
webrtc-java-javafx/target/central-*/**
webrtc-java-javafx/target/*.jar
webrtc-java-javafx/target/*.asc
natives/*.asc
if-no-files-found: error
retention-days: 7
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The library provides a comprehensive set of Java classes that map to the WebRTC
## Features

- **Complete WebRTC API implementation** - Includes peer connections, media devices, data channels, and more
- **Client API** - A high-level layer that negotiates by itself, keeps your code off WebRTC's threads, and closes everything with one call; with WHIP and WHEP sessions and a Swing video view
- **Client API** - A high-level layer that negotiates by itself, keeps your code off WebRTC's threads, and closes everything with one call; with WHIP and WHEP sessions, and video views for Swing and, with the `webrtc-java-javafx` module, JavaFX
- **Cross-platform support** - Works on Windows, macOS, and Linux (x64, ARM, ARM64)
- **Media capabilities** - Audio and video capture from cameras and microphones
- **Desktop capture** - Screen and application window sharing
Expand Down
3 changes: 3 additions & 0 deletions design/client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,9 @@ Next:
takes client API senders and remote tracks: `dev.onvoid.webrtc.client.internal.EncodedFrames`,
exported to the media module only, hands it their encoded frames, taken on the peer's control
executor, where key frame requests run too, and do nothing once the sender or receiver is gone.
- `VideoView` for JavaFX lives in the `webrtc-java-javafx` module, package
`dev.onvoid.webrtc.client.javafx`, compiled for Java 11 since OpenJFX is; JavaFX is an optional
dependency the application brings.
- phase 2 is done: `Whip.to(...).publish(rtc)` and
`Whep.from(...).play(rtc)` return sessions over `HttpURLConnection` (Java 8), and `VideoView` is in
`dev.onvoid.webrtc.client.swing`;
Expand Down
29 changes: 29 additions & 0 deletions docs/guide/client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,35 @@ frame.add(remoteView, BorderLayout.CENTER);

`snapshot()` returns a copy of the picture shown, for saving a still or for tests.

For JavaFX, the `webrtc-java-javafx` module has a `VideoView` node in `dev.onvoid.webrtc.client.javafx` that works the same way. It needs Java 11 and the JavaFX your application already uses:

```xml
<dependency>
<groupId>dev.onvoid.webrtc</groupId>
<artifactId>webrtc-java-javafx</artifactId>
<version>{{ VERSION }}</version>
</dependency>
```

```java
import dev.onvoid.webrtc.client.javafx.VideoView;

WebRtc rtc = WebRtc.builder()
.eventExecutor(Platform::runLater) // handlers on the JavaFX Application Thread
.build();

VideoView remoteView = new VideoView();
peer.onTrack(track -> {
if (track.isVideo()) {
track.asVideo().onFrame(remoteView);
}
});

stage.setScene(new Scene(new StackPane(remoteView), 960, 540));
```

The view converts frames on their own thread and paints at most once per JavaFX pulse. `setMirrored(true)`, or its `mirroredProperty()`, flips a camera preview, and `snapshot()`, on the JavaFX Application Thread, returns a copy of the picture.

### Don't Wait in a Handler

A future of the client API completes on the event thread of its peer. A handler that waits for one would wait for its own thread, so `join()` and `get()` there throw a `BlockingCallException` instead of hanging. Chain the next step instead:
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<module>webrtc-jni</module>
<module>webrtc</module>
<module>webrtc-java-media</module>
<module>webrtc-java-javafx</module>
<module>webrtc-examples</module>
</modules>

Expand Down
69 changes: 69 additions & 0 deletions webrtc-java-javafx/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>dev.onvoid.webrtc</groupId>
<artifactId>webrtc-java-parent</artifactId>
<version>0.21.0-SNAPSHOT</version>
</parent>

<artifactId>webrtc-java-javafx</artifactId>

<name>webrtc-java-javafx</name>
<description>
JavaFX extension for webrtc-java. Shows the video of the client API in JavaFX scenes.
</description>

<properties>
<!-- The oldest OpenJFX line still served, which runs on Java 11. An
application brings the JavaFX it uses; this module only compiles
against it. -->
<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>
<artifactId>webrtc-java</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Optional: an application that uses this module has JavaFX already,
in the version it chose. -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${javafx.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>
Loading
Loading