srs Enhance HTTP Streaming, HTTP Callback, HTTP API for HTTP-FLV, HTTPS, HLS etc.

j2cgzkjk  于 2022-12-31  发布在  其他
关注(0)|答案(6)|浏览(317)

SRS支持HTTP有几个应用:

SRS4或SRS5若增强HTTP流媒体服务的能力,使用起来会更方便,一致性也比较强。

bmvo0sr5

bmvo0sr51#

There is a work-around:

Use nginx or go-oryx/httpx-static to covert HTTP to HTTPS, or HTTPS直播实战,搞定HTTPS-HLS和HTTPS-FLV

Whatever, SRS will support HTTPS client and server inside.

deikduxw

deikduxw2#

HTTPS Client protocol:

  • Wiki: SRS Callback for HTTPS Server.

HTTP callback support HTTPS server, for example, conf/https.hooks.callback.conf :

vhost __defaultVhost__ {
    http_hooks {
        enabled         on;
        on_connect      https://127.0.0.1:443/api/v1/clients;
    }
}

The log of SRS, for https-client:

[2020-11-03 15:47:58.645][Trace][4715][h6r1ehdh] RTMP client ip=127.0.0.1:61658, fd=10
[2020-11-03 15:52:35.021][Trace][5547][2m457139] https: connected to https://127.0.0.1:443, cost=6ms
[2020-11-03 15:47:58.658][Trace][4715][h6r1ehdh] http: on_connect ok, client_id=h6r1ehdh, 
url=https://127.0.0.1:443/api/v1/clients, request={"action":"on_connect", 
"client_id":"h6r1ehdh","ip":"127.0.0.1","vhost":"__defaultVhost__","app":"live",
"tcUrl":"rtmp://127.0.0.1:1935/live","pageUrl":""}, 
response={"code": 0, "data": null}

Note: The wireshark capture file for HTTPS client: https-client.pcapng.zip

Note: Refer to OpenSSL example using memory BIO with non-blocking socket IO .

bzzcjhmw

bzzcjhmw3#

HTTPS API server protocol:

Config for HTTPS API, for example, conf/https.rtc.conf :

http_api {
    enabled         on;
    listen          1985;
    # For https_api or HTTPS API.
    https {
        # Whether enable HTTPS API.
        # default: off
        enabled on;
        # The listen endpoint for HTTPS API.
        # default: 1990
        listen 1990;
        # The SSL private key file, generated by:
        #       openssl genrsa -out server.key 2048
        # default: ./conf/server.key
        key ./conf/server.key;
        # The SSL public cert file, generated by:
        #       openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net"
        # default: ./conf/server.crt
        cert ./conf/server.crt;
    }
}

Open in Chrome:

The SRS logs:

[2020-11-06 17:14:10.700][Trace][21509][551p56t8] https: api server done, use key 
./conf/server.key and cert ./conf/server.crt, cost=5ms
[2020-11-06 17:14:10.700][Trace][21509][551p56t8] HTTP #0 127.0.0.1:62381 GET 
https://127.0.0.1:1990/api/v1/versions, content-length=-1

# For self-sign certificate, there is always a error:
[2020-11-06 17:17:35.939][Error][21509][551p56t8][0] serve error code=4042 : start : handshake : handshake r0=-1, r1=1
thread [21509][551p56t8]: do_cycle() [src/app/srs_app_http_conn.cpp:170][errno=0]
thread [21509][551p56t8]: on_start() [src/app/srs_app_http_api.cpp:1710][errno=0]
thread [21509][551p56t8]: handshake() [src/app/srs_app_conn.cpp:624][errno=0]

Note: Capture files https-server-port-1443.pcapng.zip , https-server.pcapng.zip

Note: Refer to OpenSSL example using memory BIO with non-blocking socket IO .

ht4b089n

ht4b089n4#

值得好好做,打好HTTP基础。

ssgvzors

ssgvzors5#

HTTP-API相关的Issue,都汇总到这个issue更新:

carvr3hs

carvr3hs6#

期待SRS4能支持HLS的clients统计和HLS的on_play/on_stop回调

相关问题