ossrs / srs

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
25.32k stars 5.33k forks source link

API styling problem: mixed property cases in HTTP events #3580

Closed amethystdev1 closed 1 year ago

amethystdev1 commented 1 year ago

Note: Please read FAQ before file an issue, see #2716

Description

Please description your issue here

  1. SRS Version: 5.0.0

  2. SRS Log: -

  3. SRS Config:


listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;

http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}

http_api {
    enabled         on;
    listen          1985;
}

stats {
    network         0;
}

rtc_server {
    enabled on;
    listen 8000; # UDP port
    # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
    candidate $CANDIDATE;
}

vhost __defaultVhost__ {
    http_hooks {
        # Enable http hooks
        enabled         on;

        # When a stream was published
        on_publish      http://backend:4004/srs/on_publish;

        # When a user tries to play stream
        on_play         http://backend:4004/srs/on_play;
    }

    rtc {
        enabled     on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
        rtmp_to_rtc on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
        rtc_to_rtmp off;
    }

    min_latency on;
    play {
        mw_latency      0;
        mw_msgs         0;
        queue_length    10;
    }

Replay

Please describe how to replay the bug?

Step 1: Set up any HTTP callback to your server on any event, e.g. on_publish Step 2: Look at the payload SRS had sent to your callback application

 {
   server_id: 'vid-71198av',
   service_id: '2k00276t',
   action: 'on_publish',
   client_id: '832d4148',
   ip: '192.168.0.101',
   vhost: '__defaultVhost__',
   app: 'live',
   tcUrl: 'rtmp://192.168.0.3/live',
   stream: '6481c661da46bb4695ab7f08',
   param: '?token=Ipj4zpxABO_ivfvkna4_cRhc22ubiLoLrZO33TSsAprtZCSOZXhfi67G8uF2ZMM2F9f0LVypxGn4wrs7sSBvF7M7zp-rPPIu',
   stream_url: '/live/6481c661da46bb4695ab7f08',
   stream_id: 'vid-9m7ri6w'
 }

Step 3: Everything is OK according to documentation, but...

Expect

It would be nice if server_id, service_id, client_id, tcUrl, stream_url, stream_id have been of the same variable naming case: either camelCase or snake_case.

Additionally, there is pageUrl property in on_play event.

I propose using snake_case and renaming tcUrl to tc_url and pageUrl to page_url to avoid converting other properties to camelCase.

xiaozhihong commented 1 year ago

image

The tcUrl and pageUrl properties are specific keywords in RTMP and should not be altered in style. However, other properties should follow the style guidelines of SRS.