Rust VoIP - Janus LiveKit Server #1: Giới thiệu khóa học - Setup LiveKit Server
Bài 111:42|1 phút trước|Rust VoIP: LiveKit Media Server

Rust VoIP - Janus LiveKit Server #1: Giới thiệu khóa học - Setup LiveKit Server

Chào mừng các bạn đến với bài học đầu tiên của khóa học lập trình Rust VoIP. Trong video này, chúng ta sẽ bắt đầu làm quen với LiveKit Media Server – một giải pháp Media Server thế hệ mới mạnh mẽ, giúp đơn giản hóa việc xây dựng các hệ thống VoIP phức tạp so với các mô hình truyền thống

1. Tổng quan về mô hình VoIP:

Nhìn lại mô hình thực tế của các hệ thống Call Center (App-to-App, SIP-to-App, Auto Call Out) và sự chuyển dịch từ cấu hình Janus phức tạp sang mô hình LiveKit tối giản hơn.

Ưu điểm của LiveKit Media Server: Tìm hiểu cách LiveKit tự động xử lý các tác vụ khó khăn như build/rewind SDP hay phân tích candidate, giúp lập trình viên sử dụng dễ dàng thông qua các hàm có sẵn thay vì phải can thiệp sâu vào kỹ thuật.

2. Hướng dẫn cài đặt chi tiết bằng Docker:

Sử dụng Docker Compose để thiết lập hệ thống gồm 3 thành phần chính: Redis (hỗ trợ clustering), LiveKit Server, và LiveKit SIP

Cấu hình mạng ở chế độ network_mode: host để xử lý các bản tin SIP và luồng WebRTC hiệu quả

Cấu hình hệ thống (Configuration):

Thiết lập các tham số quan trọng như: API Port (7880), dải RTC Port (50.000 - 60.000), External IP cho VPS và cấu hình Webhook để colback về module Rust

Kết nối giữa LiveKit SIP và LiveKit Server thông qua API Key và Secret để bảo mật

Lộ trình khóa học: Sau bài học cài đặt này, chúng ta sẽ lần lượt triển khai các tính năng: cấu hình nhận cuộc gọi, xử lý DTMF, thực hiện gọi tự động và kết nối đa nền tảng giữa WebRTC và SIP.

3. livekit.yaml

port: 7880
rtc:
  port_range_start: 50000
  port_range_end: 60000
  tcp_port: 7881
  use_external_ip: true

keys:
  your_api_key: b1b1073d08639ed260d1963e7135b44a

logging:
  level: info

redis:
  address: localhost:6380

webhook:
  urls:
    - http://103.216.118.205:20004/livekit/event
  api_key: your_api_key

4. sip.yaml

api_key: your_api_key
api_secret: b1b1073d08639ed260d1963e7135b44a
ws_url: ws://localhost:7880

sip_port: 40005
udp_port: 40005

rtp_port: 10000
rtp_port_count: 500

external_ip: 103.216.118.205
use_external_ip: true

logging:
  level: debug

redis:
  address: localhost:6380

5. docker-compose.yaml

version: '3.8'
services:
  redis:
    image: 'redis:7-alpine'
    container_name: 'livekit-redis'
    volumes:
      - ./data/redis:/data
    command: redis-server --save 60 1 --appendonly yes
    ports:
      - '6380:6379'
    restart: 'unless-stopped'
  livekit:
    image: 'livekit/livekit-server:latest'
    container_name: 'livekit-server'
    volumes:
      - './config/livekit.yaml:/etc/livekit.yaml'
      - './souds:/etc/souds'
    command: '--config /etc/livekit.yaml'
    restart: 'unless-stopped'
    network_mode: 'host'
    depends_on:
      - 'redis'
  livekit-sip:
    image: 'livekit/sip:latest'
    container_name: 'livekit-sip'
    command: '--config /etc/sip.yaml'
    environment:
      - 'LIVEKIT_URL=ws://localhost:7880'
      - 'LIVEKIT_API_KEY=your_api_key'
      - 'LIVEKIT_API_SECRET=your_api_key'
    depends_on:
      - 'livekit'
    volumes:
      - './config/sip.yaml:/etc/sip.yaml'
    restart: 'unless-stopped'
    network_mode: 'host'