dash.js
dash.js copied to clipboard
Make language matching robust against variants
dash.js provides the setInitialMediaSettings API to select an AdaptationSet by language.
The implementation compares the string provided in value.lang
against the string read from the @lang
attribute in the MPD for the respective AdaptationSet. This comparison is implemented using the String:Prototyp:match()
function which also supports regular expressions (see /src/streaming/controllers/MediaController.js ).
However, language tags provided both via the MPD and through the API may use both 2 and 3-letter versions as well as extended language tags for the same language regularly. An example is an MPD using @lang=“spa”
while the API is called with lang=”es-US”
, both requesting the Spanish language. Consequently, they should match (see BCP-47/RFC 5646) but there appears no straightforward way to achieve this using the current API and RegEx patterns.
We would suggest to enable dash.js with a configurable "language matcher" that can be supplied by the caller if more robust matching is necessary or desired. npm/bcp47-match might be a good candidate.
Alternatively, npm/bcp47-match could be hard-baked into dash.js but that would increase the footprint (not by much, but still) for all users.
@wschidol Thank you for sharing this. If npm/bcp47-match does the mapping dash.js would benefit from this. In this case, it should not be an external library that the app needs to add manually, but we should use and include it directly in dash.js. I don't consider the increase in the bundle size by 18kb a blocker.
Having said this, is this something you can provide as a PR to dash.js?
Having said this, is this something you can provide as a PR to dash.js?
We will follow up with a PR, yes.
Work on this item progresses in #4015 .
@wschidol Can we close this with the changes from #4015?
@dsilhavy : Yes, can be closed If discussions at MPEG turns out that additional enhancements are needed or beneficial, I'll open a new issue.