oryx使用webrtc的直播延迟平均在一秒内,适合实现大疆机场的无人机实时遥感直播,这里采用大疆机场二代,docker部署oryx,镜像版本:registry.cn-hangzhou.aliyuncs.com/ossrs/oryx:5,部署环境采用Ubuntu 22.04.5 LTS,使用nginx代理oryx请求

nginx配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
server {
    listen       80;
    listen       443 ssl http2;
    # 替换成自己的域名
    server_name  domain.com;
    ssl_certificate      /etc/nginx/cert/domain.com.pem;
    ssl_certificate_key  /etc/nginx/cert/domain.com.key;

    # 静态控制台与播放器
    location ~ ^/(console|mgmt|terraform|players)/ {
        proxy_pass              https://127.0.0.1:2443;
        proxy_ssl_server_name   on;
        proxy_set_header        Host              $host;
        proxy_set_header        X-Real-IP         $remote_addr;
        proxy_set_header        X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_redirect          https://127.0.0.1:2443/   https://$host/;
    }

    # For SRS streaming, for example:
    #   http://r.ossrs.net/live/livestream.flv
    #   http://r.ossrs.net/live/livestream.m3u8
    location ~ ^/.+/.*\.(flv|m3u8|ts|aac|mp3)$ {
        proxy_pass https://127.0.0.1:2443;
        proxy_ssl_verify off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
   
    # For SRS backend API for console.
    # For SRS WebRTC publish/play API.
    location ~ ^/(api|rtc)/ {
       proxy_pass http://127.0.0.1:1985$request_uri;
    }
}

使用docker运行oryx容器:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
version: '3'
services:
  emqx:
    image: registry.cn-hangzhou.aliyuncs.com/ossrs/oryx:5
    container_name: oryx
    hostname: "oryx"
    ports:
      - 2022:2022 # oryx控制台端口
      - 2443:2443 # oryx https端口
      - 1935:1935 # rtmp协议端口
      - 1985:1985 # http api端口
      - 8000:8000/tcp # webrtc tpc协议端口
      - 8000:8000/udp # webrtc udp协议端口
      - 10080:10080
    restart: always
    volumes:
      - ./data:/data
      - ./conf:/usr/local/oryx/platform/containers/conf
    environment:
      - CANDIDATE=218.77.59.59 # 服务器可以被客户端访问的ip
      - SRS_RTC_SERVER_TCP_ENABLED=on # 开启webrtc tpc连接方式
      - SRS_RTC_SERVER_PROTOCOL=all

修改配置

打开conf目录下srs.release.conf文件,找到http_api这一块,将127.0.0.1:1985改成1985,不然容器外部访问不到srs的程序:

1
2
3
4
5
6
7
8
http_api {
    enabled         on;
    listen          1985;
    raw_api {
        enabled on;
        allow_reload on;
    }
}

启动容器后使用浏览器访问oryx的控制台,配置好secret

下发开启直播指令给大疆机场

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"tid": "fdca4023gff",
"bid": "5d6cca3dsss",
"timestamp": 1746518282291,
"gateway": "7CTXMAU00B0322",
"data": {
"url_type": 4,
"url": "http://domain.com/rtc/v1/whip/?app=live&stream=test&secret=308a238ed0234d84b2b3ed143d03f47d",
"video_id": "7CTXMAU00B0322/165-0-7/normal-0",
"video_quality": 0
},
"method": "live_start_push",
"needReply": 1
}

注意:目前机场2 webrtc直播在国内仅支持http,在海外支持https的dolby服务器