feat(call): integrate LiveKit for voice and video calling
All checks were successful
Build Backend / build (push) Successful in 3m47s
Build Backend / build-docker (push) Successful in 5m9s

Replace the manual WebRTC signaling implementation with LiveKit SFU. This includes:
- Adding LiveKit service, handler, and configuration.
- Updating Docker Compose to include LiveKit server, Redis, and PostgreSQL.
- Refactoring `CallService` and `WSHandler` to support LiveKit room readiness instead of raw SDP/ICE relaying.
- Adding new API endpoints for LiveKit token generation and webhooks.
- Removing deprecated WebRTC configuration and manual signaling DTOs.
This commit is contained in:
2026-06-01 13:41:02 +08:00
parent 9356cb6876
commit 14114db68d
22 changed files with 731 additions and 452 deletions

View File

@@ -39,6 +39,7 @@ type RouterDeps struct {
QRCodeHandler *handler.QRCodeHandler
MaterialHandler *handler.MaterialHandler
CallHandler *handler.CallHandler
LiveKitHandler *handler.LiveKitHandler
ReportHandler *handler.ReportHandler
AdminReportHandler *handler.AdminReportHandler
VerificationHandler *handler.VerificationHandler
@@ -83,6 +84,7 @@ type Router struct {
qrcodeHandler *handler.QRCodeHandler
materialHandler *handler.MaterialHandler
callHandler *handler.CallHandler
liveKitHandler *handler.LiveKitHandler
reportHandler *handler.ReportHandler
adminReportHandler *handler.AdminReportHandler
verificationHandler *handler.VerificationHandler
@@ -130,6 +132,7 @@ func New(deps RouterDeps) *Router {
qrcodeHandler: deps.QRCodeHandler,
materialHandler: deps.MaterialHandler,
callHandler: deps.CallHandler,
liveKitHandler: deps.LiveKitHandler,
reportHandler: deps.ReportHandler,
adminReportHandler: deps.AdminReportHandler,
verificationHandler: deps.VerificationHandler,
@@ -462,10 +465,20 @@ func (r *Router) setupRoutes() {
calls.Use(authMiddleware)
{
calls.GET("/history", r.callHandler.GetCallHistory)
calls.GET("/ice-servers", r.callHandler.GetICEServers)
}
}
// LiveKit 通话路由
if r.liveKitHandler != nil {
lk := v1.Group("/calls")
lk.Use(authMiddleware)
{
lk.GET("/token", r.liveKitHandler.GetToken)
}
// Webhook 不需要认证LiveKit 服务端调用)
v1.POST("/calls/webhook", r.liveKitHandler.HandleWebhook)
}
// 消息操作路由
messages := v1.Group("/messages")
messages.Use(authMiddleware)