Closed winlinvip closed 2 years ago
srt://127.0.0.1:10080?streamid=#!::h=live/livestream?secret=xxx&token=yyy,m=publish',In software based on libavformat implementation, the parameters after '&' will be ignored by ffmpeg. The streamid passed out will be truncated to '#!::h=live/livestream?secret=xxx'.
参考如下设计是否可行'
Please let me know the specific design you are referring to so that I can provide an accurate translation.
With one parameter: SRT: 'srt://127.0.0.1:10080?streamid=#!::h=live/livestream,secret=xxx,m=publish' RTMP: rtmp://127.0.0.1/live/livestream?secret=xxx
With multiple parameters SRT: 'srt://127.0.0.1:10080?streamid=#!::h=live/livestream,secret=xxx,token=yyy,m=publish' RTMP: rtmp://127.0.0.1/live/livestream?secret=xxx&token=yyy This type of single-letter format like 'h' and 'm' belongs to Standard Keys according to the official srt documentation. They cannot be customized for use. On the other hand, 'secret' and 'token' are custom keys. The value after 'streamid' will be passed to the other end during the srt handshake. Additionally, tools like ffmpeg support other parameters that can be connected using '&', but they can only be used locally in ffmpeg. For reference on the ffmpeg srt URL format, you can visit ffmpeg srt URL format. Using the mentioned format will not conflict with the av_find_info_tag parsing function in ffmpeg and is fully compliant with the official srt definition.
"In addition, since the secret is within the stream and livestream is a string, it requires the playback to also include the secret. This makes it impossible to authenticate only the push stream without authenticating the pull stream, and it also makes it impossible to use different secrets (or tokens) for push and playback." This means that all parameters are placed within the stream.
TRANS_BY_GPT3
The parameters of RTMP must all be placed in the stream, not in the app.
Originally, Adobe placed them in the app, but this looks messy.
rtmp://127.0.0.1/live?secret=xxx&token=yyy?vhost=live.test.com/livestream
It's better to place them naturally in the stream.
rtmp://127.0.0.1/live/livestream?secret=xxx&token=yyy?vhost=live.test.com
Therefore, the parameters of RTMP must not be placed in the app anymore. SRS supports placing them in the app for compatibility purposes, but the new ones cannot be placed here anymore.
TRANS_BY_GPT3
After checking the current URL formats of Tencent and Bilibili, it seems that they are different from what we have defined.
Tencent:
srt://${rtmp-push-domain}:9000?streamid=#!::h=${rtmp-push-domain},r=${app}/${stream},txSecret=${txSecret},txTime=${txTime}
Bilibili:
Server address:
srt://live-push.bilivideo.com:1937?streamid=#!::h=live-push.bilivideo.com,r=live-bvc/?streamname=live_430256302_28738971,key=ad890c602709895446f8fb994a01393b,schedule=srtts,pflag=1
Stream key:
?streamname=live_430256302_28738971&key=ad890c602709895446f8fb994a01393b
Please make sure to determine which URL format to use and finalize the conclusion in the document. Otherwise, readers will be confused, users won't know how to use it, and the code will need to be constantly modified.
We should prioritize the documentation. The document should be finalized before working on the code. The code is ultimately meant for the users, and if we ourselves don't understand it, how can we expect the users to know how to use it?
In addition, the previous relevant documents need to be updated. Documentation is more important than code. If the documentation is not updated, even if the code is updated, it will be useless. No one will go through the code in detail just to understand how to use it.
Please everyone, first put your thoughts into a document and write them in the comments of this PR. Then I will schedule a Tencent meeting to finalize a time. Once we have confirmed, I will share it in the SRT group for others to review and see if there are any additions.
I would like to propose a few objectives:
Please everyone, first share your thoughts so that we can reach a consensus on this.
TRANS_BY_GPT3
Thanks @xiaozhihong @zhouxiaojun2008
Because SRT does not defines the querystring, or because streamid IS actually a querystring, so it's hard to use authentication in SRT URL. For example, a general SRT url defines as bellow:
How to pass something like
secret=xxx
in the URL? It's undefined, so we defined as:It also allows us to pass more than one querystring, for example:
SRT does not define QueryString, so there will be problems when switching to RTMP, and authentication cannot be done.
Usage
OBS streaming address:
rtmp://127.0.0.1/live/livestream?key1=value1&key2=value2
srt://127.0.0.1:10080?streamid=#!::r=live/livestream,key1=value1,key2=value2,m=publish
With VHOST parameter:
rtmp://127.0.0.1/live/livestream?vhost=host.com&key1=value1&key2=value2
srt://127.0.0.1:10080?streamid=#!::h=host.com,r=live/livestream,key1=value1,key2=value2,m=publish
FFPLAY playback address:
rtmp://127.0.0.1/live/livestream?key1=value1&key2=value2
srt://127.0.0.1:10080?streamid=#!::r=live/livestream,key1=value1,key2=value2,m=request
With authentication information:
rtmp://127.0.0.1/live/livestream?secret=xxx
srt://127.0.0.1:10080?streamid=#!::r=live/livestream,secret=xxx,m=publish
Publish by FFmpeg:
Play by ffplay:
Solution
If using domain (vhost) for push-pull streaming, the general correspondence between RTMP and SRT is:
rtmp://host.com/app/stream?key1=value1&key2=value2
srt://host.com:10080?streamid=#!::h=host.com,r=app/stream,key1=value1,key2=value2
It is also possible to directly use the IP to specify the domain for push-pull streaming.
rtmp://1.2.3.4/app/stream?vhost=host.com&key1=value1&key2=value2
srt://1.2.3.4:10080?streamid=#!::h=host.com,r=app/stream,key1=value1,key2=value2
Sometimes (often), SRS does not have a domain name (domain/vhost) and directly uses IP for push-pull streaming. In such cases:
rtmp://1.2.3.4/app/stream?key1=value1&key2=value2
srt://1.2.3.4:10080?streamid=#!::r=app/stream,key1=value1,key2=value2
Key points:
&
symbol should not be used, as it will be treated as a parameter separator by ffmpeg and OBS, resulting in the loss of input parameters.h=hostname
parameter needs to be included again in thestreamid
, whereas for RTMP, it is not required. This is because RTMP automatically includes thehostname
in thetcUrl
, while in SRT, it needs to be manually specified to differentiate the business domain.m=request|publish
represents whether it is a pull or push stream. The default is a pull stream.Regarding the definitions of
h
andr
, please refer to SRT: Standard Keys.r
: Resource Name identifies the name of the resource and facilitates selection should the listener party be able to serve multiple resources.h
: Host Name identifies the hostname of the resource. For example, to request a stream with the URIsomehost.com/videos/querry.php?vid=366
thehostname
field should havesomehost.com
, and the resource name can havevideos/querry.php?vid=366
or simply366
. Note that this is still a key to be specified explicitly. Support tools that apply simplifications and URI extraction are expected to insert only the host portion of the URI here.m
: Mode expected for this connection:request
(default): the caller wants to receive the streampublish
: the caller wants to send the stream databidirectional
: bidirectional data exchange is expectedReference document:
Compatible
The previously defined old URL format mainly included the stream information in the
h
parameter. It is currently still compatible, but it will be removed in the future. Please refrain from using it.Based on the article from the official SRT website: AccessControl
The latest modification to the SRT streaming address specification is:
URL for defaultVhost
URL for vhost
Based on the SRT official website, the format of the stream ID has Standard Keys. The SRT service in SRS should strive to comply with the official website standards.
Comply with the YAML format, starting with #!::. The key "h" represents the vhost and appname/stream. The key "m" represents publishing (publish) or requesting (request) a stream.
TRANS_BY_GPT3