Skip to content

Commit

Permalink
docs: add autogenerated documentation site
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmarc committed Dec 11, 2024
1 parent 987b8ed commit 74be462
Show file tree
Hide file tree
Showing 14 changed files with 587 additions and 20 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
on:
push:
branches: [main, docs]

name: Build documentation site
jobs:
build:
name: Build
runs-on: ubuntu-24.04
steps:
- uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v4
with:
submodules: true

- name: install protoc
run: |
sudo apt update
sudo apt instal protobuf-compiler
- name: install zola
uses: taiki-e/install-action@v2
with:
tool: [email protected]

- name: generate config reference
run: |
mkdir -p docs/content/reference
cargo run --manifest-path mm-docgen/Cargo.toml --bin config-docgen \
mmserver.default.toml > docs/content/reference/config.md
- name: generate protocol reference
run: |
cargo run --manifest-path mm-docgen/Cargo.toml --bin protocol-docgen \
mm-protocol/src/messages.proto > docs/content/reference/protocol.md
- name: zola build
run: zola -r docs build -o docs/build

- name: generate rustdoc for mm-protocol
run: |
cargo doc --manifest-path mm-protocol/Cargo.toml \
--no-deps --target-dir docs/build
- name: generate rustdoc for mm-client-common
run: |
cargo doc --manifest-path mm-client-common/Cargo.toml \
--no-deps --target-dir docs/build
- name: Upload static files
id: deployment
uses: actions/upload-pages-artifact@v3
with:
path: docs/build
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4




3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "docs/themes/anemone"]
path = docs/themes/anemone
url = https://github.com/Speyll/anemone
3 changes: 3 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# autogenerated
content/reference
build/
15 changes: 15 additions & 0 deletions docs/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
base_url = "https://colinmarc.github.io/magic-mirror"
theme = "anemone"
compile_sass = false
build_search_index = false

[markdown]
highlight_code = true

[extra]
twitter_card = false
header_nav = [
{ url = "/", name_en = "/home/"},
{ url = "https://github.com/colinmarc/magic-mirror", name_en = "/github/"},
{ url = "", name_en = "/discord/"},
]
40 changes: 40 additions & 0 deletions docs/content/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
+++
+++

# Magic Mirror 🪞✨

This page contains documentation for [Magic Mirror](github.com/colinmarc/magic-mirror),
an open-source game streaming and remote desktop tool for linux hosts.

### Download

These links always point to the latest release.

- 💾 [Server [mmserver-0.5.6]](https://github.com/colinmarc/magic-mirror/releases/tag/mmserver-v0.5.6)
- 💾 [Command-Line Client [mmclient-0.4.1]](https://github.com/colinmarc/magic-mirror/releases/tag/mmclient-v0.4.1)
- 💾 [macOS GUI Client](https://github.com/colinmarc/magic-mirror-swiftui/releases/latest)

### Setup Guides

Start here to get things up and running.

- ⚙️ [Server Setup](@/setup/server.md)
- ⚙️ [Client Setup](@/setup/client.md)
<!-- - ⚙️ [Running on a Cloud VPS](./setup/vps.md) -->
<!-- - ⚙️ [Troubleshooting and Known Issues](@/setup/troubleshooting.md) -->

### Reference

Autogenerated from the code.

- 📖 [Configuration Reference](@/reference/config.md)
- 📖 [Protocol Reference](@/reference/protocol.md)
- 📖 [Rustdoc for `mm-protocol`](./doc/mm_protocol)
- 📖 [Rustdoc for `mm-client-common`](./doc/mm_client_common)

### Resources

Get help, report issues, make friends.

- ⁉️ [Issue Tracker](https://github.com/colinmarc/magic-mirror/issues)
- 💬 [Discord Chat](https://discord.gg/v22G644DzS)
50 changes: 50 additions & 0 deletions docs/content/setup/client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
+++
title = "Client Setup"

[extra]
toc = true
+++

## macOS GUI Client

The native macOS client can be downloaded from [the releases page](https://github.com/colinmarc/magic-mirror-swiftui/releases/latest).

It should work out of the box on ARM and Intel Macs running macOS 10.14 or
later.

## Installing the commandline client

There is also a cross-platform commandline client, `mmclient`. You can download
it [here](https://github.com/colinmarc/magic-mirror/releases/tag/mmclient-v0.4.1).

The commandline client requires `ffmpeg` 6.0 or later to be installed on the
system. It also requires up-to-date Vulkan drivers.

## Building mmclient

The following are required to build the client and its dependencies:

```
rust (MSRV 1.77.2)
nasm
cmake
protoc
libxkbcommon (linux only)
libwayland-client (linux only)
alsa (linux only)
ffmpeg 6.x
```

Besides Rust itself, the following command will install everything on ubuntu:

```
apt install \
nasm cmake protobuf-compiler libxkbcommon-dev libwayland-dev libasound2-dev \
ffmpeg libavutil-dev libavformat-dev libavdevice-dev libavfilter-dev
```

Or using homebrew on macOS:

```
brew install nasm cmake ffmpeg@6 protobuf
```
134 changes: 134 additions & 0 deletions docs/content/setup/server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
+++
title = "Server Setup"

[extra]
toc = true
+++

## Quickstart

First, grab [the latest server release](https://github.com/colinmarc/magic-mirror/releases/tag/mmserver-v0.5.6) and untar it somewhere:

```sh
curl -fsSL "https://github.com/colinmarc/magic-mirror/releases/download/mmserver-v0.5.6/mmserver-v0.5.6-linux-amd64.tar.gz" \
| tar zxv
cd mmserver-0.5.6
```

Then, create a [configuration file](@/reference/config.md) with at least one application definition:

```toml
# mmserver.toml
[apps.steam-gamepadui]
command = ["steam", "-gamepadui"]
xwayland = true
```

Then you can start the server like so:

```
$ ./mmserver -C config.toml
2024-12-09T16:57:30.989261Z INFO mmserver: listening on [::1]:9599
```

You can also create a configuration directory, and add a file (json or toml) for each application:

```sh
mkdir apps.d
echo 'command = ["steam", "-gamepadui"]' > apps.d/steam.toml
./mmserver -i apps.d
```

## Connectivity

By default, mmserver only listens on `localhost`, which is not terribly
useful. There are a few different options to configure which socket address the
server listens for connections on.

The easiest is to bind to a local IP, or use a VPN like wireguard or tailscale:

```toml
# config.toml
[server]
bind = "192.168.1.37"
```

Or from the command line:

```sh
mmserver --bind $(tailscale ip -4):9599
```

If you'd like to stream on a public IP, or on all interfaces (with `0.0.0.0`),
mmserver requires that you set up a TLS certificate and key:

```toml
# config.toml
[server]
tls_cert = "/path/to/tls.key"
tls_key = "/path/to/tls.cert"
```

Generating such certificates and adding them to the client is out of scope for
this guide. Note that while all Magic Mirror traffic is encrypted with TLS
(whether you supply certificates or not), no _authentication_ is performed on
incoming connections.

Finally, you can also use `--bind-systemd` or `bind_systemd = true` to bind to a
[systemd socket](https://www.freedesktop.org/software/systemd/man/latest/systemd.socket.html).

## Hardware/software encoding

Magic Mirror uses video compression codecs to stream the game over the wire.
Hardware encoding using the GPU is needed to get the best performance and latency.
CPU-based encode is available as a fallback, but it's slower, albeit slightly
higher quality.

To see if your GPU supports video encoding, see the following matrix for your vendor:
- [AMD](https://en.wikipedia.org/wiki/Unified_Video_Decoder#Format_support)
- [NVIDIA](https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new)

Note that with the `ffmpeg_encode` feature, linking against a system-installed `ffmpeg`
is supported, which may allow you to use specific CPU-based codecs not considered
in this table.

| Codec | CPU | AMD | NVIDIA | Intel |
| ----- | :-: | :-: | :----: | :---: |
| H.264 |||||
| H.265 |||||
| AV1 |||||

## Building `mmserver` from source

The following are required to build the server and its dependencies:

```
rust (MSRV 1.77.2)
nasm
cmake
protoc
libxkbcommon
```

Besides Rust itself, the following command will install everything on ubuntu:

```
apt install nasm cmake protobuf-compiler libxkbcommon-dev
```

Then you should be good to go:

```
cd mm-server
cargo build --bin mmserver [--release]
```

### Feature flags

The following feature flags are available:

- `vulkan_encode` (on by default) - enables hardware encode
- `svt_encode` (on by default) - enables svt-av1 and svt-hevc for CPU encode
- `ffmpeg_encode` - allows using system-installed ffmpeg to do CPU encode

Note that `ffmpeg_encode` takes precedence over `svt_encode` if enabled, but the server will always choose hardware encode if available on your platform.
Empty file added docs/templates/footer.html
Empty file.
1 change: 1 addition & 0 deletions docs/themes/anemone
Submodule anemone added at ae125d
54 changes: 54 additions & 0 deletions mm-docgen/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions mm-docgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "mmserver-config-docgen"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "config-docgen"

[[bin]]
name = "protocol-docgen"

[dependencies]
regex = "1"
Loading

0 comments on commit 74be462

Please sign in to comment.