Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion modules/config/schemas_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Literal

from confz import BaseConfig
from pydantic import ConfigDict, Field
from pydantic import ConfigDict, Field, model_validator
from pydantic.types import Annotated, ClassVar, NonNegativeInt, PositiveInt


Expand Down Expand Up @@ -211,6 +211,7 @@ class HTTP(BaseConfig):

filename: ClassVar = "http.yml"
http_server: HTTPServer = Field(default_factory=lambda: HTTPServer())
webrtc: WebRTC = Field(default_factory=lambda: WebRTC())


class OBS(BaseConfig):
Expand Down Expand Up @@ -242,6 +243,29 @@ class HTTPServer(BaseConfig):
port: Annotated[int, Field(gt=0, lt=65536)] = 8888


class WebRTC(BaseConfig):
"""Schema for the webrtc section in the HTTP config."""

enabled: bool = False
turn: WebRTCTurn | None = None


class WebRTCTurn(BaseConfig):
"""Schema for the webrtc.turn section in the HTTP config."""

urls: list[str]
secret: str

@model_validator(mode="after")
def check_turn_settings(self) -> "WebRTCTurn":
if len(self.urls) == 0:
raise ValueError("`urls` must contain at least one TURN server URL.")
for url in self.urls:
if not url.startswith(("turn:", "turns:")):
raise ValueError(f"TURN server URL '{url}' must start with 'turn:' or 'turns:'.")
return self


class ProfileMetadata(BaseConfig):
"""Schema for the metadata configuration file part of profiles."""

Expand Down
15 changes: 15 additions & 0 deletions modules/config/templates/http.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,18 @@ http_server:
enable: false
ip: 127.0.0.1
port: 8888

# WebRTC can be used to stream video and audio data to the web UI. It also has a
# channel for inputs, so the bot can be controlled remotely.
# Requires the `aiortc` package.
webrtc:
enabled: false
# Only needed if browsers cannot reach the bot's IP address directly, e.g. if the bot runs
# in a Docker container or in a NAT environment.
turn: null
#turn:
# urls:
# - turn:bot.example.com:3478?transport=udp
# - turn:bot.example.com:3478?transport=tcp
# # Shared secret, the same as coturn's `static-auth-secret`
# secret: long-random-string
Loading
Loading