Dash.js: Stream with URL with CDN token and media chunk downloading

Created on 6 Dec 2017  路  3Comments  路  Source: Dash-Industry-Forum/dash.js

Hello,

We are trying to play a stream that includes CDN tokens. If the token is not in the url, the file is forbidden for downloading. For security reasons, I am not able to share you the real url, but here is the example:

http://.../1-0-alwo-2015/video/Manifest.mpd?28XZGQhD_qD6d3YccM6384g9PoaO4tQpt0DcwGglPG_1yKJuK8bausubS0nc8Q7fuZmkUlrgYzsoQd3wlV6k7kBJH9r965YS7ow

If I remove the token from url, the stream will not start, as the manifest is forbidden for downloading:

http://.../1-0-alwo-2015/video/Manifest.mpd

If I start the stream, then the manifest is downloaded correctly, but as soon as the dashjs starts downloading audio and video chunks then it fails. The reason for this is that the same token should be added into each chunk request URL.

This URL for media chunk fails:

http://.../1-0-alwo-2015/video/video-H264-396-1000k_dashinit.mp4

This URL will download file:

http://.../1-0-alwo-2015/video/video-H264-396-1000k_dashinit.mp4?28XZGQhD_qD6d3YccM6384g9PoaO4tQpt0DcwGglPG_1yKJuK8bausubS0nc8Q7fuZmkUlrgYzsoQd3wlV6k7kBJH9r965YS7ow

I've tried this:
player.setXHRWithCredentialsForType("MediaSegment", true);

and this:
player.setXHRWithCredentials(true);

Is there any support for this in dashjs or should we modify player according to our needs.

Any help on this will be greatly appreciated! Thanks

Question

Most helpful comment

@herrsiim, two alternative approaches commonly used that avoids you to extend the client:

  • Include the token in the mpd when defining media (chunks) urls. This implies returning a different mpd to each user that is not always possible.
  • Use a query string token for mpd request. Use a cookie based token for the next ones.

All 3 comments

You will need to extend the RequestModifier module and add the token to the segment URLs using modifyRequestURL, as described in https://github.com/Dash-Industry-Forum/dash.js/issues/1471#issuecomment-229291235

@herrsiim, two alternative approaches commonly used that avoids you to extend the client:

  • Include the token in the mpd when defining media (chunks) urls. This implies returning a different mpd to each user that is not always possible.
  • Use a query string token for mpd request. Use a cookie based token for the next ones.

Closing this one. @herrsiim, please feel free to reopen this one in case something is not clear.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattlohkamp picture mattlohkamp  路  4Comments

NguyenTungs picture NguyenTungs  路  5Comments

fabienvallee picture fabienvallee  路  3Comments

sandersaares picture sandersaares  路  5Comments

redd29 picture redd29  路  4Comments