Skip to content

Commit ac4a711

Browse files
authored
Add auto-generated CLAUDE.md (#21)
1 parent 232d9b1 commit ac4a711

1 file changed

Lines changed: 129 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
**obs-moq** is an OBS Studio plugin that enables streaming via the Media over QUIC (MoQ) protocol. The plugin consists of three main components:
8+
- **MoQ Service** (`moq-service.cpp/h`): Configures the connection to a MoQ relay (server URL, path, supported codecs)
9+
- **MoQ Output** (`moq-output.cpp/h`): Handles the streaming output, manages the session with the MoQ server, and processes audio/video data packets
10+
- **MoQ Source** (`moq-source.cpp/h`): Experimental feature for receiving MoQ broadcasts
11+
12+
The plugin wraps `libmoq`, a Rust library (located at `../moq/rs/libmoq`) that handles the MoQ protocol implementation via FFI bindings.
13+
14+
## Build Commands
15+
16+
### Initial Setup
17+
```bash
18+
# Configure the project (auto-detects platform: macos, ubuntu-x86_64, windows-x64)
19+
just setup
20+
21+
# For local moq development, specify path to moq repo
22+
just setup ../moq
23+
```
24+
25+
### Building
26+
```bash
27+
# Build the plugin (auto-detects platform preset)
28+
just build
29+
30+
# Build with specific preset
31+
just build macos
32+
just build ubuntu-x86_64
33+
just build windows-x64
34+
```
35+
36+
### Code Quality
37+
```bash
38+
# Check formatting (C++ with clang-format, CMake with gersemi)
39+
just check
40+
41+
# Automatically fix formatting issues
42+
just fix
43+
```
44+
45+
### Installing the Plugin
46+
47+
After building, copy the plugin to OBS:
48+
49+
**macOS:**
50+
```bash
51+
cp -a build_macos/RelWithDebInfo/obs-moq.plugin ../obs-studio/build_macos/frontend/RelWithDebInfo/OBS.app/Contents/PlugIns/
52+
```
53+
54+
**Linux:**
55+
```bash
56+
cp build_x86_64/obs-moq.so ~/.config/obs-studio/plugins/obs-moq/bin/64bit/obs-moq.so
57+
```
58+
59+
### Running OBS with Debug Logging
60+
```bash
61+
# macOS
62+
RUST_LOG=debug RUST_BACKTRACE=1 OBS_LOG_LEVEL=debug ../obs-studio/build_macos/frontend/RelWithDebInfo/OBS.app/Contents/MacOS/OBS
63+
```
64+
65+
## Architecture
66+
67+
### Plugin Registration Flow
68+
1. `obs_module_load()` in `obs-moq.cpp` initializes the plugin
69+
2. Calls `moq_log_level()` to configure Rust library logging
70+
3. Registers three components: service, output, and source
71+
72+
### Streaming Architecture
73+
1. **Service Layer**: `MoQService` stores server URL and path, validates configuration, and provides codec lists
74+
2. **Output Layer**: `MoQOutput` creates an origin and broadcast, establishes a session with the MoQ server, initializes video/audio tracks, and sends encoder packets
75+
3. **MoQ Library**: The Rust `libmoq` handles QUIC transport, MoQ protocol framing, and network I/O
76+
77+
### Key Data Flow
78+
- OBS encoder packets → `MoQOutput::Data()``VideoData()`/`AudioData()``moq_track_send_*()` FFI calls
79+
- The plugin uses callbacks for session state (connect/close) notifications
80+
81+
## Dependencies
82+
83+
- **OBS Studio**: libobs (version 31.1.1 sources in `.deps/`)
84+
- **libmoq**: Rust library via CMake FetchContent (downloads pre-built binaries from GitHub releases)
85+
- Version specified in `CMakePresets.json` (`MOQ_VERSION: 0.2.0`)
86+
- Platform-specific targets: `aarch64-apple-darwin`, `x86_64-unknown-linux-gnu`, `x86_64-pc-windows-msvc`
87+
- For local development: use `just setup ../moq` to point to local moq repository
88+
- **FFmpeg**: libavcodec, libavutil, libswscale, libswresample (via pkg-config)
89+
90+
## Code Style
91+
92+
- Use `./build-aux/run-clang-format` for C++ formatting
93+
- Use `./build-aux/run-gersemi` for CMake formatting
94+
- Both tools support `--check` (CI) and `--fix` (auto-format) modes
95+
96+
## Logging
97+
98+
Use the macros defined in `logger.h`:
99+
- `LOG_DEBUG(format, ...)` - Verbose debugging info
100+
- `LOG_INFO(format, ...)` - General information
101+
- `LOG_WARNING(format, ...)` - Warnings
102+
- `LOG_ERROR(format, ...)` - Errors
103+
104+
All logs are prefixed with `[obs-moq]` to distinguish from other OBS output.
105+
106+
## Testing
107+
108+
Connect to development server:
109+
- URL: `http://localhost:4443/anon`
110+
- Path: Any unique string (e.g., `obs`, `test123`)
111+
- Watch at: `https://moq.dev/watch/?name=<your-path>`
112+
113+
Connect to production test server:
114+
- URL: `https://cdn.moq.dev/anon`
115+
116+
## Platform-Specific Notes
117+
118+
- **macOS**: Builds universal binaries (arm64), requires Xcode generator
119+
- **Linux**: Uses Ninja generator, requires `ninja-build`, `pkg-config`, `build-essential`
120+
- **Windows**: Uses Visual Studio 17 2022 generator
121+
122+
## CMake Configuration
123+
124+
- Presets are defined in `CMakePresets.json`
125+
- Platform detection is automatic via `just preset` command
126+
- Key options:
127+
- `MOQ_LOCAL`: Path to local moq repository for development
128+
- `ENABLE_FRONTEND_API`: Enable OBS frontend API (currently OFF)
129+
- `ENABLE_QT`: Enable Qt functionality (currently OFF)

0 commit comments

Comments
 (0)