Contributing#
Workflow#
- Fork the repository on GitHub
- Create a feature branch from
main:Wheregit checkout -b feature/NNN-descriptionNNNis the issue number (if applicable). - Make your changes — write tests first, then implementation
- Verify everything passes (see below)
- Submit a Pull Request back to
main
Branch Naming#
Use the pattern feature/NNN-description:
feature/042-rtmps-support
feature/099-configurable-backpressure
fix/117-amf0-null-decode
docs/update-troubleshootingCommit Messages#
Follow Conventional Commits:
feat(relay): add reconnection with exponential backoff
fix(chunk): handle extended timestamp in FMT 3 continuation
test: add golden vectors for H.265 sequence headers
docs: update CLI reference with new auth flags
refactor(amf): simplify object end detectionScopes match package names: handshake, chunk, amf, control, rpc, conn, server, auth, hooks, media, relay, metrics.
Definition of Done#
Before submitting a PR, verify every item:
- Compiles:
go build ./... - Vet clean:
go vet ./...reports no issues - Formatted:
gofmt -l .prints nothing - Tests pass:
go test ./internal/... -count=1 - Race-free:
go test -race ./... - No dead code: no unused functions, types, or variables
- Doc comments: all exported types and functions have documentation comments
- CLI flags documented: any new flags are documented in the CLI reference
Verification Commands#
Run all checks in one command:
go build ./... && go vet ./... && gofmt -l . && go test ./internal/... -count=1For a thorough check including the race detector:
go build ./... && go vet ./... && go test -race ./... -count=1How to Add a New Feature#
1. Create the Package#
Add a new package under internal/rtmp/ following the existing pattern:
internal/rtmp/yourfeature/
├── yourfeature.go # Implementation
└── yourfeature_test.go # TestsEach package should have a single clear responsibility. Depend only on packages below you in the stack — never import a sibling or parent package.
2. Write Tests First#
Start with golden binary vectors if your feature touches the wire format:
- Create
.binfiles intests/golden/with exact expected byte sequences - Write table-driven tests that decode the golden files and verify output
- Write round-trip tests: encode → decode → compare
For non-wire-format features, write tests using net.Pipe() for real connection testing.
3. Integrate#
Wire your feature into the existing flow:
- Commands: Add handlers in
internal/rtmp/rpc/and integrate via the command dispatcher - Media processing: Add to the media dispatch path in
internal/rtmp/conn/ - Server-level features: Add configuration to
internal/rtmp/server/config.goand initialization toserver.go - CLI flags: Add flag parsing in
cmd/rtmp-server/main.go
4. Add Hook Events (If Applicable)#
If your feature has lifecycle events that external systems should know about:
- Define the event type in
internal/rtmp/server/hooks/ - Fire the event at the appropriate point in your code
- Document the event payload
5. Document#
- Add or update documentation in
site/content/docs/ - Update the CLI reference if you added flags
- Add a changelog entry