We do not change the URL of any segments. CDN changes via our playlist request. I want to explain in depth. Assume that;
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="mp4a.40.2",URI="7-audio_ts.m3u8?cdnToken=A"
#EXT-X-STREAM-INF:BANDWIDTH=1020800,CODECS="mp4a.40.2",RESOLUTION=768x432,FRAME-RATE=25.000,AUDIO="mp4a.40.2"
0-video_768_432_ts.m3u8?cdnToken=A
#EXT-X-STREAM-INF:BANDWIDTH=1680800,CODECS="mp4a.40.2",RESOLUTION=960x540,FRAME-RATE=25.000,AUDIO="mp4a.40.2"
1-video_960_540_ts.m3u8?cdnToken=A
It is our Master playlist which has one sound and two video profiles. AVPlayer starts to request at 0-video_768_432_ts.m3u8?cdnToken=A video profile which has our token knowledge in query parameters. AVPlayer gets response playlist which we assume the first playlist;
#EXT-X-VERSION:3
#EXTINF:10.0
https://chunk1?cdntoken=A.ts
#EXTINF:10.0
https://chunk2?cdntoken=A.ts
#EXTINF:10.0
https://chunk3?cdntoken=A.ts
#EXTINF:10.0
It plays 30 seconds because it has three chunks and each chunk 10 seconds long for that playlist. It gets another playlist from our CDN while player is working. Playlist will has chunk URLs in order like chunk4, chunk5, chunk6 etc. with old token which is A when get response from CDN. We can intercept playlists request via AVAssetResourceLoaderDelegate. So that, we can change 0-video_768_432_ts.m3u8?cdnToken=A playlist request like 0-video_768_432_ts.m3u8?cdnToken=B at a given time. That request can be changed after 1 minutes. CDN generates Chunk urls with cdnToken=B and because of new URL request.
Second Playlist;
#EXT-X-VERSION:3
#EXTINF:10.0
https://chunk4?cdntoken=A.ts
#EXTINF:10.0
https://chunk5?cdntoken=A.ts
#EXTINF:10.0
https://chunk6?cdntoken=A.ts
#EXTINF:10.0
Third Playlist;
#EXT-X-VERSION:3
#EXTINF:10.0
https://chunk7?cdntoken=B.ts
#EXTINF:10.0
https://chunk8?cdntoken=B.ts
#EXTINF:10.0
https://chunk9?cdntoken=B.ts
#EXTINF:10.0
As you can see the first and second playlists has old token but third playlist has new token at chunk URLs due to we call the third playlist with 0-video_768_432_ts.m3u8?cdnToken=B. It causes stalling. We want to handle that stalling. Is there any way to do it? Or Is there any another solution for that problem?