from __future__ import annotations

from aiortc import RTCPeerConnection
from fastapi import FastAPI

from config import settings
from core.state_machine import Arbitrator
from services.avatar import AvatarService
from webrtc.audio_track import build_audio_track
from webrtc.tracks import AudioBus
from webrtc.video_track import build_video_track


def attach_webrtc_tracks(
    pc: RTCPeerConnection,
    avatar_service: AvatarService,
    arbitrator: Arbitrator,
    audio_bus: AudioBus,
) -> None:
    pc.addTrack(build_video_track(avatar_service, arbitrator, audio_bus, settings.avatar_fps))
    pc.addTrack(build_audio_track(audio_bus))


def register_gateway_routes(app: FastAPI) -> None:
    # Gateway endpoints are currently implemented in `main.py`.
    # This function exists to keep project structure aligned with task list.
    _ = app
