srt icon indicating copy to clipboard operation
srt copied to clipboard

What are the rules for parsing a StreamID?

Open eric opened this issue 3 years ago • 7 comments

In Access Control it says:

  • : - this marks the YAML format, the only one currently used

but the example says:

key1=value1,key2=value2...

YAML uses : to separate a key and value, not =, so it is very confusing to me what the actual syntax is for these key/value pairs.

eric avatar Jun 25 '21 19:06 eric

Hi @eric. Thanks for noticing. The reference to YAML is indeed incorrect, as : must be used there. The provided example key1=value1,key2=value2... is the one to follow. The Guideline document has to be fixed.

maxsharabayko avatar Aug 19 '21 15:08 maxsharabayko

Can you give an example with curly braces (the nesting) and an example of how to handle a value with a =, , , and in it (escaping)?

eric avatar Aug 20 '21 02:08 eric

Like:

#!:{u=john,sig={simple,ext=spliced,expires=never},m=publish}

In particular: in case of nested braces, whatever's inside the paired braces, shall not be part of the syntax. The resulting values here are:

  • u: john
  • sig: simple,ext=spliced,expires=never (to be parsed separately, not necessarily according to the overall syntax)
  • m: publish

If you specified the same thing with :: syntax:

#!::u=john,sig={simple,ext=spliced,expires=never},m=publish 

Values would be then interpreted as:

  • u: john
  • sig: {simple
  • ext: spliced
  • expires: never}
  • m: publish

Note that that's only a conceptual syntax, I don't think anyone has so far implemented it.

ethouris avatar Aug 20 '21 07:08 ethouris

How is escaping supposed to be handled here?

Could I get an example or description of what syntax Haivision is using in their SRT solutions right now? I'd like to try to match it.

eric avatar Aug 21 '21 00:08 eric

Depends on what level of specification you mean.

On the lowest possible level you have the SRTO_STREAMID socket option, which's type is a string with specified length. This one has only one limitation: NUL characters cannot be stored directly there, that's all. Beside this, all character code values are allowed.

Above this there's the Access Control specification, which mandates this string to be UTF-8 encoded and defines the syntax. Beside key/value syntax elements and the required ability to parse it according to these rules, rest of the things are free-form. In case of braced syntax it means that when you have an open brace, until the symmetric closing brace, everything is free-form (in the frames of UTF-8 encoding). If you want to pass any kind of "binary data", including NUL character, the way how to encode and decode them is not part of this specification.

And above this there's another level, which is the URI specification in the applications, where the streamid key in the attribute part is used to set this option. This, again, should follow the overall URI specification and follow the guidelines of the URI standard, and any "escaping" takes place there (which might be necessary for some key syntax elements in the streamid specification). The default applications provided with SRT handle this, and normally applications must handle it somehow on their own.

ethouris avatar Aug 23 '21 11:08 ethouris

During the plugfest I was shown the Haivision UI with the "Default" vs "Custom" "Stream ID Format".

The Access Control specification does not specify a format with enough detail to implement it in code. This is the reason why I have been asking for rules around escaping of values. For instance, what if the r= or h= has a , in it?

eric avatar Aug 23 '21 19:08 eric

Yes, so for that reason there exists also the braced syntax. Then I agree that the specification is too defective and requires to be completed. I think this should be simply described in a separate issue with a request to fix the specification.

ethouris avatar Aug 24 '21 09:08 ethouris