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
5 changes: 4 additions & 1 deletion design/client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -815,4 +815,7 @@ Next:
`Whep.from(...).play(rtc)` return sessions over `HttpURLConnection` (Java 8), and `VideoView` is in
`dev.onvoid.webrtc.client.swing`;
- porting the existing examples (phases 2 and 3); `MediaFilePlayerExample` is ported, with a
Record button, and `LocalTrack.closeAsync()` came with it.
Record button, and `LocalTrack.closeAsync()` came with it. `PeerConnectionExample`,
`DesktopVideoExample` and `MediaFileExample` are ported too, each over a loopback signaling.
`CodecListExample`, `EncryptedRecordingExample` and `VoiceActivityExample` stay on the core API,
which they demonstrate: the factory's codecs, encoded frame transforms and voice activity.
43 changes: 26 additions & 17 deletions docs/guide/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ mvn exec:java -D"exec.mainClass=dev.onvoid.webrtc.examples.ClientApiExample" -D"

## PeerConnection

The [`PeerConnectionExample`](https://github.com/devopvoid/webrtc-java/blob/master/webrtc-examples/src/main/java/dev/onvoid/webrtc/examples/PeerConnectionExample.java) demonstrates how to set up a peer connection with audio and video tracks to be able to send and receive media.
The [`PeerConnectionExample`](https://github.com/devopvoid/webrtc-java/blob/master/webrtc-examples/src/main/java/dev/onvoid/webrtc/examples/PeerConnectionExample.java) sends the camera and the microphone from one peer to another in the same process, with the [Client API](/guide/client-api), and logs the video frames and audio that arrive.

**Key features demonstrated:**
- Creating a `PeerConnectionFactory`
- Creating audio and video tracks
- Setting up a peer connection
- Adding tracks to the peer connection for sending media
- Implementing callbacks to receive incoming audio and video frames
- Creating a `WebRtc` runtime that captures from and plays to the audio devices
- Listing the cameras and microphones
- Opening the camera and the microphone as local tracks
- Connecting two peers through a loopback signaling, in place of a server
- Receiving the remote tracks, their frames and their audio
- Muting a received audio track, while its audio still reaches a handler

This example provides a foundation for building WebRTC applications that need to handle audio and video communication.
This example provides a foundation for building WebRTC applications that need to handle audio and video communication. Press Enter to end the call:

```bash
mvn exec:java -D"exec.mainClass=dev.onvoid.webrtc.examples.PeerConnectionExample"
```

## WHEP

Expand Down Expand Up @@ -64,17 +69,20 @@ This example is useful for understanding what codecs are available on the curren

## Desktop Video

The [`DesktopVideoExample`](https://github.com/devopvoid/webrtc-java/blob/master/webrtc-examples/src/main/java/dev/onvoid/webrtc/examples/DesktopVideoExample.java) demonstrates how to set up a peer connection with a desktop video source for screen or window capture.
The [`DesktopVideoExample`](https://github.com/devopvoid/webrtc-java/blob/master/webrtc-examples/src/main/java/dev/onvoid/webrtc/examples/DesktopVideoExample.java) shares a screen or a window from one peer to another in the same process, with the [Client API](/guide/client-api).

**Key features demonstrated:**
- Creating a `PeerConnectionFactory`
- Getting available desktop sources (screens and windows)
- Creating a `VideoDesktopSource` for capturing screen or window content
- Configuring the `VideoDesktopSource` properties
- Creating a video track with the desktop source
- Setting up a peer connection
- Listing the screens and windows that can be captured
- Capturing one of them as a local video track, with a frame rate and a largest size
- Connecting two peers through a loopback signaling, in place of a server
- Reading the resolution and frame rate the sender encodes

This example is particularly useful for applications that need to implement screen sharing or remote desktop functionality.
This example is particularly useful for applications that need to implement screen sharing or remote desktop functionality. It shares the first screen, or the first window with `window`. Under Wayland, the system asks which one to share instead.

```bash
mvn exec:java -D"exec.mainClass=dev.onvoid.webrtc.examples.DesktopVideoExample"
mvn exec:java -D"exec.mainClass=dev.onvoid.webrtc.examples.DesktopVideoExample" -D"exec.args=window"
```

## Media File

Expand All @@ -83,9 +91,10 @@ The [`MediaFileExample`](https://github.com/devopvoid/webrtc-java/blob/master/we
**Key features demonstrated:**
- Opening a media file, or a live RTSP stream, with a `MediaFileSource`
- Reading what the source contains from its `MediaInfo`
- Creating audio and video tracks from the media sources it feeds
- Adding those tracks to a peer connection
- Sending the media sources it feeds as [Client API](/guide/client-api) tracks, with `videoTrack` and `audioTrack`
- Receiving them on a second peer, connected through a loopback signaling
- Following playback through a `MediaPlayerListener`
- Closing the tracks before the source, which owns what they were made from

This example is useful for applications that stream pre-recorded media, relay an IP camera into WebRTC, or need a dependable stand-in for a camera in testing.

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/media/media-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Some of the formats FFmpeg decodes, such as H.264, H.265/HEVC and AAC, may be co

## Complete Example

See `MediaFileExample` in the `webrtc-examples` module, which opens a file, reports what it contains, creates tracks, adds them to a peer connection and follows playback to the end.
See `MediaFileExample` in the `webrtc-examples` module, which opens a file, reports what it contains, sends its tracks from one [Client API](/guide/client-api) peer to another and follows playback to the end.

```shell
mvn -pl webrtc-examples compile
Expand Down
Loading
Loading