"""
URL routing для видео API.
"""
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
    VideoRoomViewSet,
    VideoParticipantViewSet,
    VideoCallLogViewSet,
    ScreenRecordingViewSet
)
from .janus_views import JanusVideoRoomViewSet
from .token_views import VideoRoomTokenViewSet
from .livekit_views import create_livekit_room, get_livekit_config, delete_livekit_room_by_lesson, update_livekit_participant_media_state, participant_connected

router = DefaultRouter()
router.register(r'rooms', VideoRoomViewSet, basename='videoroom')
router.register(r'participants', VideoParticipantViewSet, basename='videoparticipant')
router.register(r'logs', VideoCallLogViewSet, basename='videocalllog')
router.register(r'recordings', ScreenRecordingViewSet, basename='screenrecording')

# Janus Gateway endpoints (параллельно с ion-sfu)
router.register(r'janus', JanusVideoRoomViewSet, basename='janus-videoroom')

# Token-based access (публичный доступ по токену)
router.register(r'token', VideoRoomTokenViewSet, basename='videoroom-token')

urlpatterns = [
    path('', include(router.urls)),
    # LiveKit endpoints
    path('livekit/create-room/', create_livekit_room, name='livekit-create-room'),
    path('livekit/config/', get_livekit_config, name='livekit-config'),
    path('livekit/rooms/lesson/<int:lesson_id>/', delete_livekit_room_by_lesson, name='livekit-delete-room-by-lesson'),
    path('livekit/update-media-state/', update_livekit_participant_media_state, name='livekit-update-media-state'),
    path('livekit/participant-connected/', participant_connected, name='livekit-participant-connected'),
]
