Skip to content

Commit 292031e

Browse files
authored
docs: split the client API guide and sort the navigation (#594)
The client API guide becomes an overview and eight pages, the core API steps leave Getting Started for a page of their own, and links to moved sections are sent on. Core API pages name their client API counterpart, and the overview, titles and sidebar agree.
1 parent 9411983 commit 292031e

51 files changed

Lines changed: 1769 additions & 1397 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/.vitepress/nav.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export const navbar: DefaultTheme.NavItem[] = [
1616
link: '/tools',
1717
},
1818
{
19-
text: 'Client API Design',
20-
link: '/guide/client-api-design',
19+
text: 'Client API',
20+
link: '/guide/client-api',
2121
},
2222
{
2323
text: IS_NEXT ? PROJECT_VARS.VERSION_SNAPSHOT : PROJECT_VARS.VERSION,

‎docs/.vitepress/sidebar.ts‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,24 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] {
1111
text: 'Introduction',
1212
collapsed: false,
1313
items: [
14-
{ text: 'What is webrtc-java?', link: '/introduction' },
14+
{ text: 'Introduction', link: '/introduction' },
1515
{ text: 'Getting Started', link: '/get-started' },
16+
{ text: 'Core API', link: '/core-api' },
17+
],
18+
},
19+
{
20+
text: 'Client API',
21+
collapsed: false,
22+
items: [
1623
{ text: 'Client API', link: '/client-api' },
17-
{ text: 'Client API Design', link: '/client-api-design' },
24+
{ text: 'Peers and Signaling', link: '/client/peers' },
25+
{ text: 'Threads', link: '/client/threads' },
26+
{ text: 'Sending Media', link: '/client/sending-media' },
27+
{ text: 'Receiving Media', link: '/client/receiving-media' },
28+
{ text: 'Transforms and Encryption', link: '/client/transforms' },
29+
{ text: 'Data Channels', link: '/client/data-channels' },
30+
{ text: 'WHIP and WHEP', link: '/client/whip-whep' },
31+
{ text: 'Statistics and Call Checks', link: '/client/statistics' },
1832
],
1933
},
2034
{
@@ -85,6 +99,14 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] {
8599
{ text: 'GraalVM Native Image', link: '/advanced/native-image' },
86100
],
87101
},
102+
{
103+
text: 'Background',
104+
collapsed: false,
105+
items: [
106+
{ text: 'Client API Design', link: '/client-api-design' },
107+
{ text: 'Build Notes', link: '/build' },
108+
],
109+
},
88110
]
89111
}
90112

@@ -97,7 +119,7 @@ function sidebarTools(): DefaultTheme.SidebarItem[] {
97119
{ text: 'Audio Converter', link: '/audio/audio-converter' },
98120
{ text: 'Audio Recorder', link: '/audio/audio-recorder' },
99121
{ text: 'Audio Player', link: '/audio/audio-player' },
100-
{ text: 'Voice Activity Detector', link: '/audio/voice-activity-detector' },
122+
{ text: 'Voice Activity Detection', link: '/audio/voice-activity-detector' },
101123
],
102124
},
103125
{
@@ -113,7 +135,7 @@ function sidebarTools(): DefaultTheme.SidebarItem[] {
113135
collapsed: false,
114136
items: [
115137
{ text: 'Screen Capturer', link: '/desktop/screen-capturer' },
116-
{ text: 'Window Capturer ', link: '/desktop/window-capturer' },
138+
{ text: 'Window Capturer', link: '/desktop/window-capturer' },
117139
{ text: 'Power Management', link: '/desktop/power-management' },
118140
],
119141
},

‎docs/.vitepress/theme/ApiNote.vue‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script setup lang="ts">
2+
import { withBase } from 'vitepress'
3+
4+
// Tells the reader of a page that shows only the core API which API it is, and
5+
// where the client API page that does the same is. It goes right below the
6+
// title of a page that shows only the core API.
7+
defineProps<{
8+
// The client API page or section that covers the same task.
9+
client?: string
10+
// Its title, as the link text.
11+
title?: string
12+
}>()
13+
</script>
14+
15+
<template>
16+
<div class="info custom-block">
17+
<p class="custom-block-title">Core API</p>
18+
<p>
19+
This page uses the core API in <code>dev.onvoid.webrtc</code>, which leaves negotiation, threads and
20+
cleanup to you.
21+
<template v-if="client">For the client API, see <a :href="withBase(client)">{{ title }}</a>.</template>
22+
</p>
23+
</div>
24+
</template>

‎docs/.vitepress/theme/DocsHome.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async function copyDependency() {
5151
const paths = [
5252
{ label: 'START BUILDING', title: 'Your first connection', description: 'Install the library, connect two peers, and send your first audio and video.', link: '/guide/get-started', action: 'Get started', icon: 'code' },
5353
{ label: 'EXPLORE MEDIA', title: 'Bring your media', description: 'Capture a camera, share a screen, play an RTSP stream, or record a call.', link: '/guide/media/media-devices', action: 'Explore media', icon: 'video' },
54-
{ label: 'CONNECT TO MEDIA SERVERS', title: 'WHIP / WHEP', description: 'Publish live audio and video with WHIP, or receive streams with WHEP over HTTP.', link: '/guide/client-api#whip-and-whep', action: 'Explore WHIP / WHEP', icon: 'arrows' },
54+
{ label: 'CONNECT TO MEDIA SERVERS', title: 'WHIP / WHEP', description: 'Publish live audio and video with WHIP, or receive streams with WHEP over HTTP.', link: '/guide/client/whip-whep', action: 'Explore WHIP / WHEP', icon: 'arrows' },
5555
]
5656
const topics = [
5757
{ title: 'Audio & video capture', detail: 'Connect microphones, cameras, and custom sources.', link: '/guide/media/media-devices', icon: 'video' },

‎docs/.vitepress/theme/index.ts‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// https://vitepress.dev/guide/custom-theme
22
import { h } from 'vue'
3-
import type { Theme } from 'vitepress'
3+
import { inBrowser, type Theme } from 'vitepress'
44
import DefaultTheme from 'vitepress/theme'
55
import NextBanner from './NextBanner.vue'
66
import DocsHome from './DocsHome.vue'
77
import ThreadingDiagram from './ThreadingDiagram.vue'
8+
import ApiNote from './ApiNote.vue'
9+
import { movedSection } from './moved'
810
import './style.css'
911

1012
export default {
@@ -19,5 +21,33 @@ export default {
1921
enhanceApp({ app, router, siteData }) {
2022
app.component('DocsHome', DocsHome)
2123
app.component('ThreadingDiagram', ThreadingDiagram)
24+
app.component('ApiNote', ApiNote)
25+
26+
// A link to a section that moved to a page of its own goes on to that page,
27+
// in place of the old address, so that going back does not come here again.
28+
if (inBrowser) {
29+
const base = siteData.value.base
30+
const target = (url: URL) => {
31+
const path = '/' + url.pathname.slice(base.length)
32+
const moved = movedSection(path, url.hash)
33+
return moved && base + moved.slice(1)
34+
}
35+
36+
// The page that was served is the old one, so the new one is loaded in its place.
37+
const first = target(new URL(location.href))
38+
if (first) {
39+
location.replace(first)
40+
}
41+
42+
const previous = router.onBeforeRouteChange
43+
router.onBeforeRouteChange = (to) => {
44+
const moved = target(new URL(to, location.href))
45+
if (moved) {
46+
router.go(moved, { replace: true })
47+
return false
48+
}
49+
return previous?.(to)
50+
}
51+
}
2252
}
2353
} satisfies Theme

‎docs/.vitepress/theme/moved.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Sections that moved to pages of their own. A link to one of them, from a page
2+
// of an earlier release or from another site, is sent on to where it is now.
3+
export const MOVED_SECTIONS: Record<string, Record<string, string>> = {
4+
'/guide/client-api': {
5+
'peers-and-signaling': '/guide/client/peers',
6+
'signaling': '/guide/client/peers#signaling',
7+
'polite-and-impolite-peers': '/guide/client/peers#polite-and-impolite-peers',
8+
'peer-state': '/guide/client/peers#peer-state',
9+
'automatic-ice-recovery': '/guide/client/peers#automatic-ice-recovery',
10+
'threads': '/guide/client/threads',
11+
'limiting-threads': '/guide/client/threads#limiting-threads',
12+
'handlers-on-the-ui-thread': '/guide/client/threads#handlers-on-the-ui-thread',
13+
'don-t-wait-in-a-handler': '/guide/client/threads#don-t-wait-in-a-handler',
14+
'sending-media': '/guide/client/sending-media',
15+
'sending-a-media-file': '/guide/client/sending-media#sending-a-media-file',
16+
'pushing-video-and-audio': '/guide/client/sending-media#pushing-video-and-audio',
17+
'controlling-senders-and-tracks': '/guide/client/sending-media#controlling-senders-and-tracks',
18+
'switching-cameras': '/guide/client/sending-media#switching-cameras',
19+
'devices': '/guide/client/sending-media#devices',
20+
'receiving-media': '/guide/client/receiving-media',
21+
'video-frames': '/guide/client/receiving-media#video-frames',
22+
'audio': '/guide/client/receiving-media#audio',
23+
'receiving-without-sending': '/guide/client/receiving-media#receiving-without-sending',
24+
'recording': '/guide/client/receiving-media#recording',
25+
'encoded-transforms': '/guide/client/transforms',
26+
'data-channels': '/guide/client/data-channels',
27+
'whip-and-whep': '/guide/client/whip-whep',
28+
'manual-negotiation': '/guide/client/peers#manual-negotiation',
29+
'statistics': '/guide/client/statistics',
30+
'diagnosis-and-quality-events': '/guide/client/statistics#diagnosis-and-quality-events',
31+
'checking-before-a-call': '/guide/client/statistics#checking-before-a-call',
32+
},
33+
'/guide/get-started': {
34+
'using-the-core-api': '/guide/core-api',
35+
'initialize-the-webrtc-library': '/guide/core-api#initialize-the-webrtc-library',
36+
'create-a-peer-connection': '/guide/core-api#create-a-peer-connection',
37+
'signaling': '/guide/core-api#signaling',
38+
'letting-the-peer-connection-create-the-description': '/guide/core-api#letting-the-peer-connection-create-the-description',
39+
'adding-candidates-and-knowing-the-outcome': '/guide/core-api#adding-candidates-and-knowing-the-outcome',
40+
'media-streams': '/guide/core-api#media-streams',
41+
'accessing-media-devices': '/guide/core-api#accessing-media-devices',
42+
'creating-media-tracks': '/guide/core-api#creating-media-tracks',
43+
'adding-tracks-to-peer-connection': '/guide/core-api#adding-tracks-to-peer-connection',
44+
'receiving-tracks': '/guide/core-api#receiving-tracks',
45+
'cleanup': '/guide/core-api#cleanup',
46+
'finding-objects-that-were-never-disposed': '/guide/core-api#finding-objects-that-were-never-disposed',
47+
},
48+
}
49+
50+
// Where the section a path and hash name moved to, relative to the site's base, if it did.
51+
export function movedSection(path: string, hash: string): string | undefined {
52+
const page = path.replace(/\.html$/, '').replace(/\/$/, '')
53+
const anchor = decodeURIComponent(hash.replace(/^#/, ''))
54+
55+
return anchor ? MOVED_SECTIONS[page]?.[anchor] : undefined
56+
}

‎docs/guide/advanced/audio-codecs.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Audio Codecs
22

3+
<ApiNote client="/guide/client-api#the-runtime" title="The Runtime" />
4+
35
A `PeerConnectionFactory` decides which audio codecs it can send and receive through an audio encoder factory and an audio decoder factory. Unless told otherwise it uses all codecs built into WebRTC. This guide explains how to limit them, for example to offer only Opus, or to put a codec first that a remote endpoint expects.
46

57
The API lives in the `dev.onvoid.webrtc.media.audio.codec` package.

‎docs/guide/advanced/encoded-transforms.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The transform belongs to the native sender or receiver, not to the Java object:
4343

4444
### With the Client API
4545

46-
The [Client API](/guide/client-api#encoded-transforms) takes the same transforms. Those of the peer options apply to every sender and remote track of the peer, and are set before the first frame passes either way:
46+
The [Client API](/guide/client/transforms) takes the same transforms. Those of the peer options apply to every sender and remote track of the peer, and are set before the first frame passes either way:
4747

4848
```java
4949
PeerOptions.builder()

‎docs/guide/advanced/end-to-end-encryption.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ The frame format covers VP8, VP9, AV1 and every audio codec. WebRTC's packetizer
132132

133133
H.264 and H.265 frames are split at their start codes before they are sent, which a ciphertext would contain anywhere, so they are dropped with `UNSUPPORTED_CODEC`. A call has to negotiate them away, which matters on macOS in particular, where WebRTC prefers H.264 through VideoToolbox:
134134

135-
- A peer of the client API with `e2ee(keys)` does so by itself: it offers and answers only VP8, VP9 and AV1 video, in WebRTC's order. `videoCodecs(...)` of the [WHIP and WHEP](/guide/client-api#whip-and-whep) builders still picks among them, and fails the session with a `ConfigurationException` if it names none of them.
135+
- A peer of the client API with `e2ee(keys)` does so by itself: it offers and answers only VP8, VP9 and AV1 video, in WebRTC's order. `videoCodecs(...)` of the [WHIP and WHEP](/guide/client/whip-whep) builders still picks among them, and fails the session with a `ConfigurationException` if it names none of them.
136136
- Without the client API, call `setCodecPreferences` on each video transceiver with the codecs for which `KeyProvider.supportsCodec(codec.getMimeType())` is true, keeping `rtx`, `red` and `ulpfec`.
137137

138138
## Recording

‎docs/guide/advanced/field-trials.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Field Trials
22

3+
<ApiNote client="/guide/client-api#the-runtime" title="The Runtime" />
4+
35
WebRTC uses field trials to gate experimental features and tune internal behavior (e.g. congestion control, codec selection, message interleaving) without changing the public API. This guide explains how to enable them when creating a `PeerConnectionFactory`.
46

57
Field trials are applied once, at `PeerConnectionFactory` creation, and take effect for everything created by that factory (peer connections, tracks, sources). Different `PeerConnectionFactory` instances in the same process may use different field trials.

0 commit comments

Comments
 (0)