srs icon indicating copy to clipboard operation
srs copied to clipboard

希望在callback接口on_publish中增加stream_id属性

Open stormbirds opened this issue 3 years ago • 5 comments

基于现在的开发版本,我自己实现sip信令服务器的过程中,需要在邀请拉流之后获取stream信息,但是现在的on_publish回调中只有app和stream,没有stream_id,这时候我需要先通过http_api的api/v1/streams接口获取到stream列表,然后通过app和stream筛选出具体流信息,我觉得如果在on_publish回调中返回stream_id在业务端保存会更合适,这样可以基于stream_id直接获取对应的流信息。

stormbirds avatar Jan 01 '22 20:01 stormbirds

Welcome to submit a patch.' Make sure to maintain the markdown structure.

TRANS_BY_GPT3

winlinvip avatar Jan 03 '22 00:01 winlinvip

cid pubtime也有用' translates to 'cid pubtime is also useful' in English.

TRANS_BY_GPT3

jinleileiking avatar Jan 03 '22 05:01 jinleileiking

Please provide a detailed explanation of the specific application scenarios, instead of just giving a conclusion. Do not add any unnecessary information unless it is necessary.

TRANS_BY_GPT3

winlinvip avatar Jan 04 '22 01:01 winlinvip

@jinleileiking Please provide a detailed explanation of the application scenario, instead of just giving a conclusion. Do not include any unnecessary information unless it is necessary.

When there is a flash break, for example, when stream1 stops and stream2 starts, there is a rather troublesome case in distributed systems. That is, when sending callbacks or triggering transcoding tasks, these two events may be out of order. My experience is to use CID and pubtime for disorder handling. In the case of network jitter, these four messages (stream1 start, stop, stream2 start, stop) can sometimes be disordered, in extreme cases.

TRANS_BY_GPT3

jinleileiking avatar Jan 04 '22 02:01 jinleileiking

Thank you, described very clearly. 👍

TRANS_BY_GPT3

winlinvip avatar Jan 04 '22 02:01 winlinvip

Curve-saving law: Use the client_id in the callback information to query the clients interface => can obtain the stream_id.

TRANS_BY_GPT3

drchzy avatar Aug 19 '22 03:08 drchzy

Not bad, not bad, I support it. My application scenario also needs this functionality.

Actual application situation: In the list, you can see the information of the stream currently being pushed, and you can also verify the running status of the stream.

To implement this application scenario, it is necessary to directly obtain the information of the stream. However, currently, the data submitted from the hook cannot be directly obtained from the API.


The ultimate goal is to be able to directly obtain the relevant information of the stream through the API, such as modifying the API, for example, api/v1/vhost/app/stream.

TRANS_BY_GPT3

28269890 avatar Aug 19 '22 03:08 28269890

There is a way to bypass it, the callback will provide the client_id, for example:

        #       {
        #           "action": "on_publish",
        #           "client_id":"1y83d208",
        #           "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
        #           "stream": "livestream", "param":"?token=xxx&salt=yyy", "server_id": "vid-werty"
        #       }

Then, by querying this client, you can obtain the stream_id:

http://localhost:1985/api/v1/clients/1y83d208

{
  "code": 0,
  "server": "srs-ie193id",
  "client": {
    "id": "1y83d208",
    "vhost": "vid-pg0862j",
    "stream": "vid-538tx0p",
    "ip": "127.0.0.1"
  }
}

Then, using vid-538tx0p, you can retrieve the information of the stream.

TRANS_BY_GPT3

winlinvip avatar Aug 24 '22 11:08 winlinvip

Received, thank you for your hard work~

TRANS_BY_GPT3

drchzy avatar Aug 24 '22 11:08 drchzy

Received, thank you for your hard work~

TRANS_BY_GPT3

drchzy avatar Oct 11 '22 09:10 drchzy