Skip to content

Commit e53f925

Browse files
committed
docs: add build guides to the docs site
1 parent fdec335 commit e53f925

3 files changed

Lines changed: 454 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ node_modules
66
bak
77
dist
88
build*
9+
!docs/build/
10+
!docs/build/*.md
911
private
1012
doxygen2md
1113
_book

docs/build/getting-started.md

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# Getting Started
2+
3+
This page is the shortest path from zero to a working icey program.
4+
5+
If you need every build knob, install prefix, or platform package detail, use the [installation guide](installation.md). If you are still figuring out which subsystem you need, start with the [module map](../modules.md).
6+
7+
## Quick Start
8+
9+
:::steps
10+
11+
1. Add icey to your CMakeLists.txt
12+
13+
The fastest way to use icey is CMake FetchContent. No manual cloning, no system installation; CMake downloads and builds only the modules you need.
14+
15+
```cmake
16+
cmake_minimum_required(VERSION 3.21)
17+
project(myapp)
18+
19+
include(FetchContent)
20+
FetchContent_Declare(icey
21+
GIT_REPOSITORY https://github.com/nilstate/icey.git
22+
GIT_TAG 2.4.0
23+
)
24+
FetchContent_MakeAvailable(icey)
25+
26+
add_executable(myapp src/main.cpp)
27+
target_link_libraries(myapp PRIVATE icey::base icey::net icey::http)
28+
```
29+
30+
2. Link only what you need
31+
32+
Each module is a separate imported CMake target under the `icey::` namespace. Dependencies resolve automatically.
33+
34+
3. Build
35+
36+
```bash
37+
cmake -B build -DCMAKE_BUILD_TYPE=Release
38+
cmake --build build
39+
```
40+
41+
:::
42+
43+
## Available Targets
44+
45+
| Target | Module | Optional Dependencies |
46+
| ------ | ------ | --------------------- |
47+
| `icey::base` | [Base](../modules/base.md) ||
48+
| `icey::crypto` | [Crypto](../modules/crypto.md) | OpenSSL 3.x |
49+
| `icey::net` | [Net](../modules/net.md) ||
50+
| `icey::http` | [HTTP](../modules/http.md) ||
51+
| `icey::json` | [JSON](../modules/json.md) ||
52+
| `icey::av` | [AV](../modules/av.md) | FFmpeg 5+/6+/7+ |
53+
| `icey::webrtc` | [WebRTC](../modules/webrtc.md) | libdatachannel |
54+
| `icey::symple` | [Symple](../modules/symple.md) ||
55+
| `icey::stun` | [STUN](../modules/stun.md) ||
56+
| `icey::turn` | [TURN](../modules/turn.md) ||
57+
| `icey::archo` | [Archo](../modules/archo.md) ||
58+
| `icey::pacm` | [Pacm](../modules/pacm.md) ||
59+
| `icey::pluga` | [Pluga](../modules/pluga.md) ||
60+
| `icey::sched` | [Sched](../modules/sched.md) ||
61+
62+
## Building from Source
63+
64+
If you want a local build without installing system-wide:
65+
66+
```bash
67+
git clone https://github.com/nilstate/icey.git
68+
cd icey
69+
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON
70+
cmake --build build --parallel $(nproc)
71+
ctest --test-dir build --output-on-failure
72+
```
73+
74+
Then use `find_package` in your project:
75+
76+
```cmake
77+
find_package(icey REQUIRED)
78+
target_link_libraries(myapp PRIVATE icey::base icey::net icey::http)
79+
```
80+
81+
See the [installation guide](installation.md) for the full build/install path, platform-specific dependencies, and CMake options.
82+
83+
## Enabling Optional Modules
84+
85+
icey auto-detects optional system dependencies and builds the matching modules when they are available.
86+
87+
- **`icey::av`** (FFmpeg): install `libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev` (Ubuntu/Debian) or `ffmpeg` (Homebrew). Point CMake at a custom build with `-DFFmpeg_ROOT=/path/to/ffmpeg`. The `av` module builds when FFmpeg is found.
88+
- **`icey::webrtc`** (libdatachannel): requires the `av` prerequisites above plus libdatachannel. libdatachannel is fetched automatically via FetchContent when the `webrtc` module is enabled and its prerequisites are present.
89+
- **`icey::crypto`, `icey::net`, `icey::stun`, `icey::turn`** (OpenSSL): install `libssl-dev` (Ubuntu/Debian) or `openssl` (Homebrew). These modules build when OpenSSL is found.
90+
91+
For the full build matrix and all user-settable options, use [installation.md](installation.md).
92+
93+
## What You Can Build
94+
95+
### Stream a webcam to any browser
96+
97+
150 lines of C++. Camera capture, H.264 encoding, WebRTC transport, Symple signalling. Open a browser, see video.
98+
99+
```cpp
100+
session.IncomingCall += [&](const std::string& peerId) {
101+
session.accept();
102+
};
103+
104+
session.StateChanged += [&](wrtc::PeerSession::State state) {
105+
if (state == wrtc::PeerSession::State::Active) {
106+
stream.attachSource(capture.get());
107+
stream.attach(&session->media().videoSender(), 5);
108+
stream.start();
109+
}
110+
};
111+
```
112+
113+
See [`webcam-streamer`](https://github.com/nilstate/icey/tree/main/src/webrtc/samples/webcam-streamer/) or read [WebRTC in 150 Lines of C++](https://0state.com/writing/webrtc-in-150-lines-of-cpp).
114+
115+
### Record a browser's camera server-side
116+
117+
Browser sends WebRTC, your C++ server decodes with FFmpeg, writes to any format. Server-side recording without cloud vendor lock-in.
118+
119+
See [`media-recorder`](https://github.com/nilstate/icey/tree/main/src/webrtc/samples/media-recorder/).
120+
121+
### Media pipeline
122+
123+
Camera to encoder to network in four lines:
124+
125+
```cpp
126+
PacketStream stream;
127+
stream.attachSource(videoCapture);
128+
stream.attach(new av::MultiplexPacketEncoder(opts), 5);
129+
stream.attach(socket, 10);
130+
stream.start();
131+
```
132+
133+
### WebRTC peer session
134+
135+
```cpp
136+
wrtc::PeerSession::Config config;
137+
config.rtcConfig.iceServers.emplace_back("stun:stun.l.google.com:19302");
138+
config.media.videoCodec = av::VideoCodec("H264", "libx264", 1280, 720, 30);
139+
140+
wrtc::SympleSignaller signaller(client);
141+
wrtc::PeerSession session(signaller, config);
142+
143+
session.IncomingCall += [&](const std::string& peerId) {
144+
session.accept();
145+
};
146+
147+
session.StateChanged += [&](wrtc::PeerSession::State state) {
148+
if (state == wrtc::PeerSession::State::Active)
149+
startStreaming(session);
150+
};
151+
```
152+
153+
## Your First Program
154+
155+
A minimal HTTP echo server:
156+
157+
```cpp
158+
#include "icy/http/server.h"
159+
#include "icy/loop.h"
160+
161+
int main() {
162+
icy::http::Server srv{"0.0.0.0", 8080};
163+
srv.Connection += [](icy::http::ServerConnection::Ptr conn) {
164+
conn->Payload += [](icy::http::ServerConnection& conn,
165+
const icy::MutableBuffer& buf) {
166+
conn.send(icy::bufferCast<const char*>(buf), buf.size());
167+
conn.close();
168+
};
169+
};
170+
srv.start();
171+
icy::uv::runLoop();
172+
return 0;
173+
}
174+
```
175+
176+
## Next Steps
177+
178+
- Read the [module map](../modules.md) if you want the dependency picture first.
179+
- Go straight to a guide if you know the subsystem:
180+
- [Base](../modules/base.md)
181+
- [HTTP](../modules/http.md)
182+
- [WebRTC](../modules/webrtc.md)
183+
- [TURN](../modules/turn.md)
184+
- Explore the samples and apps in each module's `src/*/samples` or `src/*/apps` directories.
185+
- Read the [contributing guide](../contributing.md) if you want to work on icey itself.

0 commit comments

Comments
 (0)