1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Forward: support config full rtmp url forward to other server (#2799)

* Forward: add backend config and demo server for dynamic create forwarder to other server.(#1342)

* Forward: if call forward backend failed, then return directly.

* Forward: add API description and change return value format.

* Forward: add backend conf file and wrapper function for backend service.

* Forward: add backend comment in full.conf and update forward.backend.conf.

* Forward: rename backend param and add comment tips.
This commit is contained in:
chundonglinlin 2022-02-16 10:49:16 +08:00 committed by GitHub
parent 9379ebbc2c
commit 03cf93fc2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 335 additions and 33 deletions

View file

@ -0,0 +1,15 @@
# the config for srs to forward to slave service
# @see https://github.com/ossrs/srs/wiki/v5_CN_SampleForward
# @see full.conf for detail config.
listen 1935;
max_connections 1000;
pid ./objs/srs.backend.pid;
daemon off;
srs_log_tank console;
vhost __defaultVhost__ {
forward {
enabled on;
backend http://127.0.0.1:8085/api/v1/forward;
}
}

View file

@ -669,6 +669,37 @@ vhost same.vhost.forward.srs.com {
# active-active for cdn to build high available fault tolerance system.
# format: {ip}:{port} {ip_N}:{port_N}
destination 127.0.0.1:1936 127.0.0.1:1937;
# when client(encoder) publish to vhost/app/stream, call the hook in creating backend forwarder.
# the request in the POST data string is a object encode by json:
# {
# "action": "on_forward",
# "server_id": "vid-k21d7y2",
# "client_id": "9o7g1330",
# "ip": "127.0.0.1",
# "vhost": "__defaultVhost__",
# "app": "live",
# "tcUrl": "rtmp://127.0.0.1:1935/live",
# "stream": "livestream",
# "param": ""
# }
# if valid, the hook must return HTTP code 200(Status OK) and response
# an int value specifies the error code(0 corresponding to success):
# {
# "code": 0,
# "data": {
# "urls":[
# "rtmp://127.0.0.1:19350/test/teststream"
# ]
# }
# }
# PS: you can transform params to backend service, such as:
# { "param": "?forward=rtmp://127.0.0.1:19351/test/livestream" }
# then backend return forward's url in response.
# if backend return empty urls, destanition is still disabled.
# only support one api hook, format:
# backend http://xxx/api0
backend http://127.0.0.1:8085/api/v1/forward;
}
}